Display selected records on message box in the For

2019-07-24 04:55发布

I have a form in MS Access 2013.

form

After enter the information, select the parts and click the SEND button, parts will be sent out (insert into Table B and delete from Table A).

I would like to display selected records on the message box before the parts sending out.

message box

Is it possible? If not, could you please recommend another way for me? Thank you very much!

1条回答
神经病院院长
2楼-- · 2019-07-24 05:20

Yes, it is possible. I suppose the data is stored in a table? You can use vba on the on click event of the button as follows :

private sub buttonSend_onclick()
    Dim rs as recordset
    Dim s as string

    s = "Select * from [TableName] Where [SelectFieldName] = True"
    Set rs = Currentdb.openrecordset(s)
    s = ""
    While not rs.eof
        s = s & rs("[PartIdFieldName]") & ", "
        rs.movenext
    wend
    if s <> "" then
        s = left(s,len(s) - 2)
        s = s & "."
    else
        Msgbox "No parts selected"
    end if

    s = "Deliver parts below?" & vbcrlf & vbcrlf & s
    if(msgbox(s,vbYesNo) = vbYes) then
        ''proceed with the send
    else
        ''do not proceed with the send
    end if
end sub
查看更多
登录 后发表回答