OpenForm syntax

G

Guest

I am sure this has been talked about before, but for the life of me I have tried all the suggestions and nothing seems to work.
I have a subform that shows all the policies a client has on the client mainform. I have a double-click event on the [Policy_Number] field on the subform. This has the following code to open the policy form with all info on the policy:

Private Sub Policy_Number_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
stLinkCriteria = "Policy_Number=" & Me.Policy_Number.Value
DoCmd.OpenForm "Policy", , , stLinkCriteria,acFormEdit
End Sub

The problem is, that I get a "missing operator" message.
I have tried various combinations for stLinkCriteria, but the closest I got was a blank form, or all records coming up.
Please help.
 
M

Marshall Barton

Chakey said:
I am sure this has been talked about before, but for the life of me I have tried all the suggestions and nothing seems to work.
I have a subform that shows all the policies a client has on the client mainform. I have a double-click event on the [Policy_Number] field on the subform. This has the following code to open the policy form with all info on the policy:

Private Sub Policy_Number_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
stLinkCriteria = "Policy_Number=" & Me.Policy_Number.Value
DoCmd.OpenForm "Policy", , , stLinkCriteria,acFormEdit
End Sub

The problem is, that I get a "missing operator" message.
I have tried various combinations for stLinkCriteria, but the closest I got was a blank form, or all records coming up.


I sounds like the Policy number field might be a Text field.
If so, then you need quotes around the value:

stLinkCriteria = "Policy_Number='" & Me.Policy_Number & "'"

If not, we'll need more details about the field and its
possible values.
 
G

Guest

My field is a text field and your suggestion worked perfectly. I frequently get the number of quotes mixed up. However, you telling me it depends on whether it is a text field or not has cleared the mud a bit. Thanks again.

Marshall Barton said:
Chakey said:
I am sure this has been talked about before, but for the life of me I have tried all the suggestions and nothing seems to work.
I have a subform that shows all the policies a client has on the client mainform. I have a double-click event on the [Policy_Number] field on the subform. This has the following code to open the policy form with all info on the policy:

Private Sub Policy_Number_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
stLinkCriteria = "Policy_Number=" & Me.Policy_Number.Value
DoCmd.OpenForm "Policy", , , stLinkCriteria,acFormEdit
End Sub

The problem is, that I get a "missing operator" message.
I have tried various combinations for stLinkCriteria, but the closest I got was a blank form, or all records coming up.


I sounds like the Policy number field might be a Text field.
If so, then you need quotes around the value:

stLinkCriteria = "Policy_Number='" & Me.Policy_Number & "'"

If not, we'll need more details about the field and its
possible values.
 

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