Thread: Link Criteria and SetFocus
01-13-11, 14:20 #1Registered User
- Join Date
- Jun 2010
Unanswered: Link Criteria and SetFocus
I have a data entry form ACCOUNT(master) that has a subform, STATUS. STATUS is a visible datasheet that shows all the status updates of the account. Status entries are required for every account.
I setfocus to subform STATUS in the last field of ACCOUNTso users tab along as if it were a single form.
Now there is a third set of information that we want to start collecting which is completely optional, form NOTES is from a related table.
I need NOTES to open and only display records that match the record (ACCOUNT) you are on
Needing an option to bypass NOTES, I decided to use an unbound form. I put an OpenForm function OnExit in the last field of ACCOUNT - to an unbound form that asks you if you want to make a note for "txtbox shows you the name of the account on other form" . The txtbox control source is =Forms![ACCOUNT]![ACCOUNTNAME] Then I have buttons YES and NO
I'm having troubling with the VBA I need for each of these buttons.
1.) YES How do I use link criteria on the YES button to get the unbound form to open the NOTES form on the same account?
I'm getting an error from what I have now:
Private Sub btnYESNOTE_Click()
On Error GoTo Err_btnYESNOTE_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "SLMNOTES"
stLinkCriteria = "[NACCOUNT]=" & Me.txtACCOUNT
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , NDATE, acNewRec
Syntax error (missing operator) in query expression '[NACCOUNT]=shows me the accounts name'.
2.) NO Setfocus on the No button? I use cmd Close Form as the function of the No button since ACCOUNT is still open, and I need to set the focus back to ACCOUNT, then to subform STATUS, datefield, new record.
01-16-11, 15:14 #2Registered User
- Join Date
- Mar 2007
If [NACCOUNT] is a string (Text) field then you need extra quotes:
stLinkCriteria = "[NACCOUNT]='" & Me.txtACCOUNT & "'"RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
Please reply to this forum so all may learn.