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!

Open a form based on a filter vaule??

Status
Not open for further replies.

ov3rdr1ve

IS-IT--Management
Oct 20, 2004
32
US
I am trying to open a form based on a filter vaule which happens to be a control already populate on my form.

I am trying something like this with no luck?

docmd.openform "frmX"

docmd.applyfilter , "[controlX]"


I am trying to open another form based on a filter of a bound textbox that is already populated.

Any Ideas?

Thanks
Chance~

 
Try this:
Code:
[blue]DoCmd.OpenForm "FormName", , , "[FieldName]=[purple][b]'[/b][/purple]" & BoundTextboxName & "[purple][b]'[/b][/purple]"[/blue]
If [blue]BoundTextboxName[/blue] is numeric, remove the single quotes in [purple]purple[/purple].

Calvin.gif
See Ya! . . . . . .
 
I have exactly what you have, but I am getting an error?

Simply stated...

I have a form open and I have a bound text box (numeric field) that contains a certain record number. I want to open another form bound to the same table and have it open up to the record that is currently listed in the text box.

All through a command button?

Any Ideas?

Thanks!
Chance~

this is what I have now

docmd.openform "frmNewJuror", , , "[jurornumber]=" & Text200 & ""

 
ov3rdr1ve . . . . .

Thats very srtange! I have it working if four different ways:

[blue][tt]"[jurornumber]=" & Text200 & ""
"[jurornumber]=" & Text200
"[jurornumber]=" & [Text200]
"[jurornumber]=" & Me!Text200 & ""[/tt][/blue]

Are you sure the name is [purple]Text200[/purple]?
Check the Name property of the control . . .
Check all spelling of names.
By any chance is the control on a subForm?

Anyway another method:
In the [blue]Command Button[/blue] replace the code with the following:
Code:
[blue]   DoCmd.OpenForm "frmNewJuror", , , , , , Str(Me!Text200)[/blue]
Then, in the [blue]OnLoad[/blue] event of the opened form, copy/paste the following:
Code:
[blue]   Dim rst As DAO.Recordset
   Dim Msg As String, Style As Integer, Title As String
   
   Set rst = Me.RecordsetClone
   rst.FindFirst "[jurornumber]=" & Val(Me.OpenArgs)
   
   If rst.NoMatch Then
      Msg = "JurorNumber '" & Me.OpenArgs & "' NOT FOUND!"
      Style = vbInformation + vbOKOnly
      Title = "Can't find 'JurorNumber' Error! . . . . ."
      MsgBox Msg, Style, Title
   Else
      Me.Bookmark = rst.Bookmark
   End If
   
   Set rst = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks man!!

I found the problem... I had my field name wrong. I needed it to be my ID field.

After I did that it worked fine.

Thanks a TON man!!

U RULE!!!!!!!!

Chance~
 
ov3rdr1ve . . . . .

Be aware: Bound textboxes can appear to have two names:

The FieldName that appears in the [blue]Control Source[/blue] & the name that appears in the [blue]Name Property[/blue]. Although their usually the same, its the name property thats used to refer to the control, and you can change the name to something more suitable for your use in code without affecting the fieldname the textbox is bound to. For instance: A textbox bound to field [purple]Invoice_Customers_Full_Name[/purple], can be changed to [purple]InvFullName[/purple]. Makes code much more easier to read . . .



Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top