Link Criteria Command Button - question (1 Viewer)

Vespertin

Registered User.
Local time
Today, 04:20
Joined
May 8, 2011
Messages
11
Hello,

I have a continuous subform (usersub) on my mainform (frmMenu) with a command button - i'm trying to set the link criteria on the button to open another form (frmtasks) based on the (studentname) field in my subform and (studentname) in (frmtask).

both fields are text and there is only ever one entry in (usersub) displayed at all times when (frmMenu) is open

I used the form wizard to generate the code and added a little bit - but its not actually working - the subform control and the form its based on are the same name (usersub) - and i'm using A2007

Private Sub Command249_Click()
On Error GoTo Err_Command249_Click


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmtask"

stLinkCriteria = "[studentname]=" & "'" & Me.Forms![frmMenu]![usersub].Form![usersub].Form![studentname] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command249_Click:
Exit Sub

Err_Command249_Click:
MsgBox Err.Description
Resume Exit_Command249_Click

End Sub

I've also tried

stLinkCriteria = "[studentname]=" & "'" & Me.Forms![frmMenu]![usersub].Form![studentname] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

to no avail. I've searched on the web - but I've not found anything that's really helped.

Thank you for any additional help
 

RuralGuy

AWF VIP
Local time
Today, 05:20
Joined
Jul 2, 2005
Messages
13,825
Try using the control source of a TextBox on the MainForm to adjust your syntax.
 

Vespertin

Registered User.
Local time
Today, 04:20
Joined
May 8, 2011
Messages
11
thanks that did the trick!
 

Users who are viewing this thread

Top Bottom