Opening form2 through form1 (1 Viewer)

sammy999

New member
Local time
Today, 08:46
Joined
Aug 16, 2017
Messages
3
Form1 has an unbound combo box (cboAge) that shows different range of ages like
10-20
21-30
and so on.
Form2 has a bound textbox (TxtAgeRange) which retrieves the calculated range of ages from a query (Age query).
I cannot have an age column in the table because age is dynamic. Therefore, I'm calculating age by using a query (Age query).
The problem is with the following code when I'm opening up the form by matching cboAge and TxtAgeRange values.

If IsNull(Ages) = False Then FilterStr = FilterStr & "([TxtAgeRange] =""" & Me!cboAge & """) AND "

I'm getting error 2501 and its asking to enter the parameter for TxtAgeRange.
I'm not familiar with vba, and searched a lot to get the right answer. I appreciate any help I can get. Thanks in advance!
 

Ranman256

Well-known member
Local time
Today, 09:46
Joined
Apr 9, 2015
Messages
4,337
docmd.openform "Form2"
forms!Form2!TxtAgeRange = forms!Form1!cboAge
forms!Form2.requery 'you MAY need this one
 

sammy999

New member
Local time
Today, 08:46
Joined
Aug 16, 2017
Messages
3
Private Sub Search_actor_Click()

Dim FilterStr As String
Dim lngLen As Long

If IsNull(Ages) = False Then DoCmd.OpenForm "Actor Search"
FilterStr = FilterStr & [Forms]![Actor Search]!TxtAgeRange = [Forms]![Search Actor]!cboAge


So I ran the above code and it's just opening up the form starting from the first field. This code is not reading the information from cboAge and matching with TxtAgeRange to extract the specified fields.
I appreciate some assistance here . Thanks!
 

Users who are viewing this thread

Top Bottom