Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Newbie Needs Help! Message Box...

Status
Not open for further replies.

Ryath

Technical User
Feb 24, 2002
84
GB
Hi all,

At the moment i have a form with a button that on press will produce a yes/no message box saying that "would you like to perform a new search" if yes it will activate filter by form mode and clear all grids (accmdcleargrid)i think... not sure :/ and if no will just activate filter by form mode!!... but not sure how to do one command after the other :/

Can anyone enlighten me??

Thx all!!

Private Sub PerformS_Click()
If MsgBox("Would You Like To Perform A New Search?", vbYesNo, "Decision time.") = vbYes Then
DoCmd.RunCommand acCmdClearGrid
Else
DoCmd.RunCommand acCmdFilterByForm
End If

End Sub

Thats what i got at the mo... scream any abuse at me saying how wrong it is!! :) Will [hammer]
 
Can't see any problem with your code. However, not sure what you mean by doing one after the other. I thought you wanted to do one OR the other. Can you explain further? Have fun! :eek:)

Alex Middleton
 
Do you mean that whatever they press, the filter by form mode will start but the clear grid should only occur if they press yes?

If you do,you're almost there, try this on for size:

Private Sub PerformS_Click()
If MsgBox("Would You Like To Perform A New Search?", vbYesNo, "Decision time.") = vbYes Then
DoCmd.RunCommand acCmdClearGrid
End If
DoCmd.RunCommand acCmdFilterByForm
End Sub

If you get an error when you press the no button, just add an Else the line above the end if

Cheers,

Pete
 
thx for the quick response... it still doesnt work get an error code 2046 and the command Cleargrid isnt available right now... i think its because the grid can only be cleared when the form is in "Filter By Form" mode.

So thats what i mean doing one command after another... the form has to be in "filterBy Form" mode THEN it can clear the grids (reset search)

Thx!! Will [hammer]
 
How about:

Private Sub PerformS_Click()
Dim Response as Integer
Response = MsgBox("Would You Like To Perform A New Search?", vbYesNo, "Decision time.")
DoCmd.RunCommand acCmdFilterByForm
If Response Then
DoCmd.RunCommand acCmdClearGrid
End If
End Sub

Have fun! :eek:)

Alex Middleton
 
now i'm really confused alex... after pusing the button it says that the accmdfilterbyform isnt available yet!!!.... dumb database!!

:/ Will [hammer]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top