Filter a form

G

Guest

I have a table that has the following fields among others, ID, DOB, OVER18,
UNDER18.

Three forms pull from this table, frmFAMMEM, frmOVER18, frmlUNDER18.

In frmFAMMEM, after the DOB is entered, a macro opens either frmOVER18 or
frmUNDER18. However, when this second form opens, it always displays the
first record in tblFAMMEM, not the corresponding record.

Any ideas?
 
G

Guest

Hi, Cleblanc.

You need to use the WHERE parameter with the OpenForm method.

In the DOB AfterUpdate event procedure:

Dim stDocName As String
Dim stLinkCriteria As String

If DateValue(DatePart("m", [DOB]) & "/" & DatePart("d", [DOB]) & "/" & _
DatePart("yyyy", [DOB]) + 18) <= Now() Then

stDocName = "frmOVER18"
Else
stDocName = "frmUNDER18"
End If

stLinkCriteria = "[ID]=" & Me![Control On Current Form Bound to ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks
 
G

Guest

I'll give it a shot. Thanks for the quick response.


Sprinks said:
Hi, Cleblanc.

You need to use the WHERE parameter with the OpenForm method.

In the DOB AfterUpdate event procedure:

Dim stDocName As String
Dim stLinkCriteria As String

If DateValue(DatePart("m", [DOB]) & "/" & DatePart("d", [DOB]) & "/" & _
DatePart("yyyy", [DOB]) + 18) <= Now() Then

stDocName = "frmOVER18"
Else
stDocName = "frmUNDER18"
End If

stLinkCriteria = "[ID]=" & Me![Control On Current Form Bound to ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks

Cleblanc said:
I have a table that has the following fields among others, ID, DOB, OVER18,
UNDER18.

Three forms pull from this table, frmFAMMEM, frmOVER18, frmlUNDER18.

In frmFAMMEM, after the DOB is entered, a macro opens either frmOVER18 or
frmUNDER18. However, when this second form opens, it always displays the
first record in tblFAMMEM, not the corresponding record.

Any ideas?
 
G

Guest

Now it won't let me edit the fields in either frmOver18 or frmUnder18.

Sprinks said:
Hi, Cleblanc.

You need to use the WHERE parameter with the OpenForm method.

In the DOB AfterUpdate event procedure:

Dim stDocName As String
Dim stLinkCriteria As String

If DateValue(DatePart("m", [DOB]) & "/" & DatePart("d", [DOB]) & "/" & _
DatePart("yyyy", [DOB]) + 18) <= Now() Then

stDocName = "frmOVER18"
Else
stDocName = "frmUNDER18"
End If

stLinkCriteria = "[ID]=" & Me![Control On Current Form Bound to ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks

Cleblanc said:
I have a table that has the following fields among others, ID, DOB, OVER18,
UNDER18.

Three forms pull from this table, frmFAMMEM, frmOVER18, frmlUNDER18.

In frmFAMMEM, after the DOB is entered, a macro opens either frmOVER18 or
frmUNDER18. However, when this second form opens, it always displays the
first record in tblFAMMEM, not the corresponding record.

Any ideas?
 
G

Guest

Hi, Cleblanc.

Please post the following properties of the frmOver18 and fromUnder18 forms"
- RecordSource
- AllowEdits
- AllowAdditions

If the RecordSource is a query, please open the query, select View, SQL, and
cut and paste the SQL.

Sprinks0

Cleblanc said:
Now it won't let me edit the fields in either frmOver18 or frmUnder18.

Sprinks said:
Hi, Cleblanc.

You need to use the WHERE parameter with the OpenForm method.

In the DOB AfterUpdate event procedure:

Dim stDocName As String
Dim stLinkCriteria As String

If DateValue(DatePart("m", [DOB]) & "/" & DatePart("d", [DOB]) & "/" & _
DatePart("yyyy", [DOB]) + 18) <= Now() Then

stDocName = "frmOVER18"
Else
stDocName = "frmUNDER18"
End If

stLinkCriteria = "[ID]=" & Me![Control On Current Form Bound to ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks

Cleblanc said:
I have a table that has the following fields among others, ID, DOB, OVER18,
UNDER18.

Three forms pull from this table, frmFAMMEM, frmOVER18, frmlUNDER18.

In frmFAMMEM, after the DOB is entered, a macro opens either frmOVER18 or
frmUNDER18. However, when this second form opens, it always displays the
first record in tblFAMMEM, not the corresponding record.

Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top