proper after ujpdate code to populate form

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