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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Criteria Question 1

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
I have several forms that are based off queries that will ask users for Criteria. If a user goes to open a form but then relizes thats not the form they want after they hit cancel on the criteria the only choice then is "END" which then they will have to go all the way out of the database and log back in.

In my options i turned off view code on error. Is there a way once a user hits cancel when prompted for criteria to make it go back to a switchboard or a certain form???

Thanks in Advance

DVannoy
A+,Network+,CNA
dvannoy@onyxes.com
 
Hi!

It depends on how you are asking for input. If you are getting input through the InputBox function then you can do something like this:

Criteriastring = InputBox(yourmessage)
If Criteriastring = "" Then
Exit form and go back to the switchboard
Else
Open the appropriate form here
End If

If you are allowing the user to input criteria on a form, then just check for empty textboxes:

If Nz(Len(TextBox.Value),0) = Then
Exit form etc.
Else
Do your stuff here
End If

hth
Jeff Bridgham
 
no,,,i'm not doing it from input boxes...im doing it from the queries that the form is linked to..like in for example a document field, it may ask "PLEASE ENTER DOCUMENT# BELOW"

and the only options are "OK" or "CANCEL"

DVannoy
A+,Network+,CNA
dvannoy@onyxes.com
 
Hi!

I think I get it now. On your switchboard form, or whatever form they are opening the query from, are you closing the form upon opening the new form? If you are are you can add this code:

Declare this in your variable section of the procedure

Dim frm as Form

DoCmd.OpenForm YourName
For Each frm in Forms
If frm.name = YourName Then
DoCmd.Close acForm, ThisForm
Exit For
End If
Next frm

Now the switchboard or other form will only close if the new form actually opens. If they hit the cancel button the form will stay open.

hth
Jeff Bridgham
 
Dim frm As Form

DoCmd.OpenForm "drum pad sampling sheet"
For Each frm In Forms
If frm.Name = "drum pad sampling sheet" Then
DoCmd.Close acForm, "main switchboard"
Exit For
End If
Next frm

I get an error if i hit cancel....maybe im not understanding this correctly..

above is what i used in the code..This code is run from a button on the switchboard..
DVannoy
A+,Network+,CNA
dvannoy@onyxes.com
 
Hi!

Maybe you should let me see what sort of error handling you have in place. Another option would be to set up the error handler this way:

On Error GoTo YourErrorHandler


YourErrorHandler:
If Err = conErrDoCmdCancelled Then
Exit Sub
End If

Assuming that fits into your error handling scheme

hth
Jeff Bridgham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top