"Query" run on moment next-form button is clicked ???

Q

Quintin

Hi,

I am wondering how a query can be performed at the moment
a next-form button is clicked. I think I need to add
something in the (Visual Basic) code that is behind the
button, but I am not really familiair with that. I want to
compare data that is filled in with a linked database. Who
can do some explaining ? Thanks a lot !

Note: this is what I have come up sofar, but it is not
working...

Private Sub Next_Click()
On Error GoTo Err_Next_Click

Dim stDocName As String
Dim stLinkCriteria As String

If [PatientLinked]![PATIENTID] <> [Patient]!
[PATIENTID] Then

MsgBox "PatienID is incorrect"
DoCmd.Close

Else

stDocName = "Subject number"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , ,
Me.Name
Me.Visible = False

End If
End If

Exit_Next_Click:
Exit Sub

Err_Next_Click:
MsgBox Err.Description
Resume Exit_Next_Click

End Sub

Quintin.
 
G

Guest

hi,
Yes this can be done. in the code behind your next form
button add:
docmd.openquery "queryname",accnormal.
i would add it just after the else word.
 
Q

Quintin

Hi,

Thanks for the reply, but that is not quite what I mean.
My 'query' (the if-then-else code) is in the code already,
but it somehow doesn't do the trick....
But maybe I need to delete that, and follow your lead...

-----Original Message-----
hi,
Yes this can be done. in the code behind your next form
button add:
docmd.openquery "queryname",accnormal.
i would add it just after the else word.
-----Original Message-----
Hi,

I am wondering how a query can be performed at the moment
a next-form button is clicked. I think I need to add
something in the (Visual Basic) code that is behind the
button, but I am not really familiair with that. I want to
compare data that is filled in with a linked database. Who
can do some explaining ? Thanks a lot !

Note: this is what I have come up sofar, but it is not
working...

Private Sub Next_Click()
On Error GoTo Err_Next_Click

Dim stDocName As String
Dim stLinkCriteria As String

If [PatientLinked]![PATIENTID] <> [Patient]!
[PATIENTID] Then

MsgBox "PatienID is incorrect"
DoCmd.Close

Else

stDocName = "Subject number"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , ,
Me.Name
Me.Visible = False

End If
End If

Exit_Next_Click:
Exit Sub

Err_Next_Click:
MsgBox Err.Description
Resume Exit_Next_Click

End Sub

Quintin.

.
.
 

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