Open form to a specific record

msu6304
04-19-2004, 02:24 PM
I would like to be able to select a record from a listbox, and then open the corresponding record in a different form, using the PhysicianID field which is the sixth (but not visible) column in the listbox. I keep getting a "missing operator" message, and I'm sure it's right in front of me, but I'm not seeing it. Help is appreciated!


DoCmd.OpenForm "frmPhysicianInfo", , , "[PhysicianID] = " & Me!lstPhys.Column(6)

MKoslof
04-19-2004, 02:45 PM
Try something like this:



Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form1"

stLinkCriteria = "[Field1]= '" & Me.ListBox1.ItemData(6) & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria

msu6304
04-19-2004, 03:05 PM
Now I get a message that the OpenForm action was cancelled. ???

MKoslof
04-19-2004, 03:08 PM
can you post your current code as it stands now?

msu6304
04-21-2004, 09:18 AM
frmPhysicianInfo is the form I want to open to the specific record, frmLook2 is the form I use to find the record and then want to close on the way out.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmPhysicianInfo"

stLinkCriteria = "[PhysicianID]= '" & Me.lstPhys.Column(6) & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmLook2", acSaveNo

MKoslof
04-21-2004, 10:02 AM
Initially comment out the .Close command, does the form load when this piece is gone? And try the itemData method I showed, not the Column() method.

msu6304
04-21-2004, 01:04 PM
Changed it to ItemData and took out the .close command, still getting the OpenForm action cancelled message. ???



Private Sub cmdGoToRecord_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmPhysicianInfo"

stLinkCriteria = "[PhysicianID]= '" & Me.lstPhys.ItemData(6) & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum