selecting matching record

G

Guest

Hi
I have following procedure which I thought would open form at matching works
order record but just opens form at new record
any help please
Thanks
Private Sub Box_No_Click()

If Box_No.Value = "VP CORR" Then
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "RETURNS"

stLinkCriteria = "[Works Order]=" & "'" & Me![Works Order] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Else
End If

End Sub
 
D

David C. Holley

Check that the properties for the RETURNS form. The DATA ENTRY
properties may be set to YES which may be the cause of the problem.
Also, try adding MSGBOX(stLinkCriteria) after the stLinkCriteria line.
This will show you exactly the value of the variable and assist in
determining if that's where the problem is. Of course, check that a
match record exists in the underlying table...

David H
 
F

Fred Boer

Dear tina:

In addition to what David suggested...

Make sure that [Works Order] is string (text) data. If it is a number, your
code needs to be modified.

HTH
Fred Boer
 

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