vb Button Values

  • Thread starter Thread starter LJG
  • Start date Start date
L

LJG

I am running some imports and exports and want to ensure users can stop the
action at stages.

I have added vbMsgBox's to my code and would like to use the vbOkCancel
button to allow a user when they select the cancel the import/export will
stop and go no further.

Can anyone tell me how a create a loop to ensure this works ok

sample code below:

Private Sub Command3_Click()
MsgBox "You are about to update your Prices, have you backed up your
data?.", vbOkCancel
DoCmd.SetWarnings False
DoCmd.RunMacro "importPrices"
MsgBox "New Prices have been imported, now about to update, do you need to
backup your data?.", vbOkCancel
DoCmd.OpenQuery "qryUpdatePrices"
DoCmd.OpenQuery "qryDeleteTempCost"
MsgBox "Prices Have Been updated.", vbOKOnly
End Sub

Thanks in advance

Les
 
It's not clear to me what you want it to do. If they answer Cancel to the
first message box, what do you want to have happen? (And why not use the
vbYesNo button, since you're asking a yes/no question!)

In order to capture the user's response, you have to invoke MsgBox as a
function, not as a sub.

Perhaps you want something like:

Private Sub Command3_Click()
If MsgBox("You are about to update your Prices, " & _
"have you backed up your data?.", vbYesNo) = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunMacro "importPrices"
If MsgBox ("New Prices have been imported, " & _
"now about to update, do you need to " & _
"backup your data?.", vbYesNo) = vbYes Then
DoCmd.OpenQuery "qryUpdatePrices"
DoCmd.OpenQuery "qryDeleteTempCost"
MsgBox "Prices Have Been updated.", vbOKOnly
End If
End If
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

vbButtons values 1
autonumber 1
exit macro from VB ?? 2
Access 2003 constantly crashing 3
Command Button Not Executing 24
2 buttons change to 1 button for one go 6
Problem with append query 1
MsgBox 3

Back
Top