pass parameters between forms

S

Shane

I have form EnterID where the user enters a WorkShopID the following code is
for the open form button which they press after entering the code

Private Sub Open_Form_Click()

On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

WorkShopID = Me![WorkShopID]

stLinkCriteria = WorkShopID
stDocName = "Entering Attendance List"
DoCmd.OpenForm stDocName, , , WorkShopID
Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

This opens the enter attendance list class where they enter the people who
attended that workshop. I want to be able to pass the workshopId entered in
the previous form to this form so they don’t have to re-enter it again. Just
wondering how you would do this.
Here's the code fo enter attendance list.

Private Sub Add_Employee_Click()
On Error GoTo Err_Add_Employee_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_Employee_Click:
Exit Sub

Err_Add_Employee_Click:
MsgBox Err.Description
Resume Exit_Add_Employee_Click

End Sub

Private Sub Cancel_Click()
Dim stDocName As String

stDocName = "Trainer Form"
DoCmd.OpenForm stDocName, , , , , acDialog
Me.Visible = False
End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub
 
O

Ofer

Use the OpenArgs of the Form open command line to pass the variable


DoCmd.OpenForm stDocName, , , , , , WorkShopID
===============================
On the OnLoad event of the second form, assign the OpenArgs to the field in
the form

Me.[WorkShopID] = Me.OpenArgs
==================================
When you pass a criteria, you have to define the field name it apply to

Change this
stLinkCriteria = WorkShopID

To
stLinkCriteria = "[WorkShopID] = " & WorkShopID
 
S

Shane

Hi Ofer,

thanks a million for that. Works perfect now!
You saved me my insanity :)

Shane

Ofer said:
Use the OpenArgs of the Form open command line to pass the variable


DoCmd.OpenForm stDocName, , , , , , WorkShopID
===============================
On the OnLoad event of the second form, assign the OpenArgs to the field in
the form

Me.[WorkShopID] = Me.OpenArgs
==================================
When you pass a criteria, you have to define the field name it apply to

Change this
stLinkCriteria = WorkShopID

To
stLinkCriteria = "[WorkShopID] = " & WorkShopID

--
\\// Live Long and Prosper \\//
BS"D


Shane said:
I have form EnterID where the user enters a WorkShopID the following code is
for the open form button which they press after entering the code

Private Sub Open_Form_Click()

On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

WorkShopID = Me![WorkShopID]

stLinkCriteria = WorkShopID
stDocName = "Entering Attendance List"
DoCmd.OpenForm stDocName, , , WorkShopID
Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

This opens the enter attendance list class where they enter the people who
attended that workshop. I want to be able to pass the workshopId entered in
the previous form to this form so they don’t have to re-enter it again. Just
wondering how you would do this.
Here's the code fo enter attendance list.

Private Sub Add_Employee_Click()
On Error GoTo Err_Add_Employee_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_Employee_Click:
Exit Sub

Err_Add_Employee_Click:
MsgBox Err.Description
Resume Exit_Add_Employee_Click

End Sub

Private Sub Cancel_Click()
Dim stDocName As String

stDocName = "Trainer Form"
DoCmd.OpenForm stDocName, , , , , acDialog
Me.Visible = False
End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub
 
N

Nathan

Also on a side note to anyone interested. If you are trying to pass a value
from an object (combo box via the notinlist), you have to grab the
uncommitted value from the combo box.

Committed value:
Me.cboTest1.Value

UnCommited Value:
Me.cboTest1.Text

Hope this helps someone out there.

Nathan

Shane said:
Hi Ofer,

thanks a million for that. Works perfect now!
You saved me my insanity :)

Shane

Ofer said:
Use the OpenArgs of the Form open command line to pass the variable


DoCmd.OpenForm stDocName, , , , , , WorkShopID
===============================
On the OnLoad event of the second form, assign the OpenArgs to the field in
the form

Me.[WorkShopID] = Me.OpenArgs
==================================
When you pass a criteria, you have to define the field name it apply to

Change this
stLinkCriteria = WorkShopID

To
stLinkCriteria = "[WorkShopID] = " & WorkShopID

--
\\// Live Long and Prosper \\//
BS"D


Shane said:
I have form EnterID where the user enters a WorkShopID the following code is
for the open form button which they press after entering the code

Private Sub Open_Form_Click()

On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

WorkShopID = Me![WorkShopID]

stLinkCriteria = WorkShopID
stDocName = "Entering Attendance List"
DoCmd.OpenForm stDocName, , , WorkShopID
Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

This opens the enter attendance list class where they enter the people who
attended that workshop. I want to be able to pass the workshopId entered in
the previous form to this form so they don’t have to re-enter it again. Just
wondering how you would do this.
Here's the code fo enter attendance list.

Private Sub Add_Employee_Click()
On Error GoTo Err_Add_Employee_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_Employee_Click:
Exit Sub

Err_Add_Employee_Click:
MsgBox Err.Description
Resume Exit_Add_Employee_Click

End Sub

Private Sub Cancel_Click()
Dim stDocName As String

stDocName = "Trainer Form"
DoCmd.OpenForm stDocName, , , , , acDialog
Me.Visible = False
End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top