message box results

W

Wendy

Hi

I'm new to the vb side of access and would like to get a message box to
display the results of a query (or query turned into sql) whilst the user is
running a macro with the option for them to cancel out of the macro if the
displayed results are not correct. I'm having trouble getting the
messagebox to act on the sql code, all I can make it do is display the code.
What am I doing wrong please? This is my code.

Wendy

Sub Bankline()
Dim strMsg, myTitle, sqlstring, style
style = vbOKCancel
sqlstring = "SELECT bank.TRANSDATE, bank.AMOUNT, bank.DETAILS,
bank.TRANSCODE,bank.CHEQUENO WHERE (([bank].[TRANSCODE]) Not Like 'CC' And
Not Like 'MSC' And Not Like 'CHG'))"

myTitle = "MsgBox bank Records" ' Define title.
msgbox "The first record in the file is " & sqlstring & vbOKCancel

If Response = vbCancel Then End

End Sub
 
N

Norman Yuan

Sub xxxxx()

If MsgBox("This is the question." & vbcr & vbcr & "Do you want to
continue?",myTitle,vbInformation+style)=vbCancel Then Exit Sub

End Sub

DO NOT (or NEVER) use "END" ( as your code "If Response = vbCancel Then
End" ) in VBA code.
 
W

Wendy

OK thanks for that, as I said I'm new to vb code. Am I doing something else
wrong because that still doesn't make vb process my sqlstring and show the
data in the messagebox?

Thanks

Wendy

Norman Yuan said:
Sub xxxxx()

If MsgBox("This is the question." & vbcr & vbcr & "Do you want to
continue?",myTitle,vbInformation+style)=vbCancel Then Exit Sub

End Sub

DO NOT (or NEVER) use "END" ( as your code "If Response = vbCancel Then
End" ) in VBA code.


Wendy said:
Hi

I'm new to the vb side of access and would like to get a message box to
display the results of a query (or query turned into sql) whilst the user
is
running a macro with the option for them to cancel out of the macro if the
displayed results are not correct. I'm having trouble getting the
messagebox to act on the sql code, all I can make it do is display the
code.
What am I doing wrong please? This is my code.

Wendy

Sub Bankline()
Dim strMsg, myTitle, sqlstring, style
style = vbOKCancel
sqlstring = "SELECT bank.TRANSDATE, bank.AMOUNT, bank.DETAILS,
bank.TRANSCODE,bank.CHEQUENO WHERE (([bank].[TRANSCODE]) Not Like 'CC' And
Not Like 'MSC' And Not Like 'CHG'))"

myTitle = "MsgBox bank Records" ' Define title.
msgbox "The first record in the file is " & sqlstring & vbOKCancel

If Response = vbCancel Then End

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top