Not quite understanding OpenArgs

G

Guest

I have a form that has a combobox on it. When you type in a value into the
combobox, then there is a button (Add Payment) that opens another form - my
Payments form. What I would like is the value that is in the combobox to
populate one of the fields on the Payments form.

I have been attempting to use OpenARgs for this but just don't have
something right.

I currently have this on the Add Payment button under OnClick
Private Sub PayBtn_Click()

DoCmd.OpenForm "Payments", acNormal, , CustomerID =
CustomerID_sel.Value, acFormAdd, , strArgs

End Sub

Then on my Payment form under OnLoad I tried this:
Private Sub Form_Open(Cancel As Integer)
strArgs = Me.OpenArgs & ""
End Sub

I want the value to carry into a field called Customer on the Payment form -
what am I missing?

Marie Perry
 
T

tina

try

Private Sub PayBtn_Click()

Dim strArgs As String
strArgs = Me!MyComboboxName

DoCmd.OpenForm "Payments", acNormal, , CustomerID =
CustomerID_sel.Value, acFormAdd, , strArgs

End Sub

you stated you're using the OnLoad event in form Payments, but the code you
posted is the Open event. suggest you use the Load event, as

Private Sub Form_Load()

Me!Customer = Me.OpenArgs

End Sub

hth
 
M

Mark

Instead of putting strArgs (which looks like a variable that hasn't been
populated anywhere) in the DoCmd.OpenForm function, put
Me.YourComboboxNameHere. This will pass the value of the combobox as the
OpenArgs to the form you're opening.

Then in the Open event of that form, just set your control equal to the
OpenArgs:
Me.Customer = Me.OpenArgs
 
G

Guest

I think that I am getting closer - I know have this on my AddPayments button
OnClick

Private Sub PayBtn_Click()

DoCmd.OpenForm "Payments", acNormal, , CustomerID =
CustomerID_sel.Value, acFormAdd, , Me!CustomerID_sel

End Sub

and I have this one the Payments Form OnLoad

Private Sub Form_Load()

Me!Customer = Me.OpenArgs

End Sub

Still not getting the value to carry through - I also have this on the the
Payments Form OnLoad

Private Sub Form_Load()
If Not Me.NewRecord Then
RunCommand acCmdRecordsGoToNew
End If
End Sub

Is that confusing things?

thanks in advance

Marie
 

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