proper after ujpdate code to populate form

K

Ken

Here is my code so far, trying to populate (open ) a form based on a
selection from list box. It isnt working, and I haven't done much of this
type of code, so any help would be appreciated. The form has query for all
records as its base.

Dim stDocName As String
Dim stLinkCriteria As String
Dim strDocName As String

With lstAntideppressantsI
If .MultiSelect = 0 Then
txtSelected = .Value
End If
End With

strDocName = "frmMedicationInfo"
stDocName = txtSelected
stLinkCriteria = "MedicationName = " & stDocName

DoCmd.OpenForm strDocName, , , stLinkCriteria
 
R

Ralph

Your variables are mixed up. Try

Dim stDocName As String
Dim stLinkCriteria As String
Dim strDocName As String


With Me.lstAntideppressantsI__
txtSelected = .Value
End With

strDocName = "frmMedicationInfo"
stLinkCriteria = txtSelected
stLinkCriteria = "MedicationName = '" & stLinkCriteria & " '"

DoCmd.OpenForm strDocName, , , stLinkCriteria
 
K

Ken

Thank you, I appreciate your time very much.
Ken

Ralph said:
Your variables are mixed up. Try

Dim stDocName As String
Dim stLinkCriteria As String
Dim strDocName As String


With Me.lstAntideppressantsI__
txtSelected = .Value
End With

strDocName = "frmMedicationInfo"
stLinkCriteria = txtSelected
stLinkCriteria = "MedicationName = '" & stLinkCriteria & " '"

DoCmd.OpenForm strDocName, , , stLinkCriteria
 

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