Filter a form

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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
 
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?
 
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?
 
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?
 
Back
Top