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

open form based on criteria

Status
Not open for further replies.

shart00

Technical User
Jun 16, 2003
63
US
on frmSwitchboard there are two buttons. (1) for opening a new record and (1) to open a form to a specific record. The problem is that how do I make the second work? If the user clicks on the second button, I need a pop up or something to appear and ask the user which record# they want to update then open to that record.
 
You could just have another control on your form that is disabled unless the user selects the 2nd option (open to specific record). The control could either be a text box where the user enters the record number they want to goto. Or, it could be a combo box from which the user can select which record they want to goto.
 
I tried this on a button that is next to a text box named occurence
DoCmd.OpenForm "frmdowntimeandpartsshortage", acNormal, , Me.RecordID = Me.occurence
also tried putting it in the filtername but it does not work, it simply opens the form on the first record
 

You could try passing the filter value via openargs.
Ie

DoCmd.OpenForm "frmdowntimeandpartsshortage", acNormal, ,OpenArgs:= YourFilterValue

On the onload event of frmdowntimeandpartsshortage
do

If OpenArgs <> "" Then
Me.Filter = yourfilterfield "=" & OpenArgs
Me.FilterOn = True
End If

Remember if you use OpenArgs that it is a string paremter.

Mordja
 
Your OpenForm method should look something like this:

DoCmd.OpenForm "frmdowntimeandpartsshortage", , , "RecordID = " & Me.Occurence

This assumes that "RecordID" form you opening contains a control whose control source is equal to RecordID. It also assumes that the current form contains a field named Occurence
 

I assumed that the form for a specific record is based on a query. If so then you can set a parameter value for the record id.

In the query for this form go to design view and click query at the top. Select "Parameters" and create a parameter name something like [RecordIDprmtr] set the data type as the same as the record id data field type.

In the RecordID field of the query in criteria type in =[RecordIDprmtr]. Save the query then open it up. It'll require a record id. Keep in mind this will only work if the user enters in a valid recordid.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top