user2652375
user2652375

Reputation: 103

Display selected records on message box in the Form of Microsoft Access 2013

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!

Upvotes: 1

Views: 3497

Answers (1)

parakmiakos
parakmiakos

Reputation: 3020

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

Upvotes: 2

Related Questions