UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Help With Form Code Needed, Office 2007    
 
   
stokey18
post Apr 17 2012, 04:33 AM
Post #1

New Member
Posts: 16



Hi, I am trying to load a form to display specific data from a combo list box. It loads the form but not displaying the data. The code I am using is:



Private Sub Command4_Click()
On Error GoTo Err_Command4_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Main Details"

stLinkCriteria = "[Last Name]=" & "'" & Me![Combo0] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command4_Click:
Exit Sub

Err_Command4_Click:
MsgBox Err.Description
Resume Exit_Command4_Click

End Sub



Any help is appreciated.
Go to the top of the page
 
+
MStef
post Apr 17 2012, 04:53 AM
Post #2

UtterAccess VIP
Posts: 1,097
From: Zagreb - Croatia



Try this:
stLinkCriteria = "[Last Name]='" & Me![Combo0] & "'"
Go to the top of the page
 
+
stokey18
post Apr 17 2012, 04:57 AM
Post #3

New Member
Posts: 16



Just tried it and it does the same as the code I am using by loading the form but without the data lookup
Go to the top of the page
 
+
zocker
post Apr 17 2012, 05:41 AM
Post #4

Utterly Eccentric and Moderator
Posts: 3,660
From: Bristol / Ipswich / Spain



Its possible that your combo box has a first, hidden column and your link is referring to that column. Have a look at this link Columns problem You might try this also:


Dim stLinkCriteria As String
Dim strLastName as String
stDocName = "Main Details"

strLastName = Me.Combo0.Column(1) 'IF it is Column 1....column count starts at 0



stLinkCriteria = "[Last Name]=" & strLastName

DoCmd.OpenForm stDocName, , , stLinkCriteria





HTH


Z
Go to the top of the page
 
+
MStef
post Apr 17 2012, 06:22 AM
Post #5

UtterAccess VIP
Posts: 1,097
From: Zagreb - Croatia



Send a short example of your MDB, (Access 2000 or 2002-2003).
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 18th May 2013 - 06:12 AM