open args syntax

M

Mark Kubicki

I am trying to pass a value to a pop-up form (without success)

on the main form, I have this code:

Private Sub Manufacturer_NotInList(NewData As String, Response As
Integer)
On Error GoTo Err_Manufacturer_NotInList

' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub

' Confirm that the user wants to add the new manufacturer.
Msg = "The manufacturer: " & NewData & " is not in the Master
Database." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
' If the user chose not to add the manufacturer, set the
Response
' argument to suppress an error message and undo changes.
Response = acDataErrContinue
MsgBox "Please try again."
Else
stDocName = "frmManufacturer_PopUp"
DoCmd.OpenForm stDocName, acNormal, , , acReadOnly, , NewData
Response = acDataErrAdded
End If

--------------------------------------
on the pop-up form I have this code:

Private Sub Form_Open(Cancel As Integer)
strNewManufacturer = Forms!FixtureCataloges.OpenArgs
Me.txtManufacturerName = strNewManufacturer
End Sub

but the result is not the value I want,but the name of a control on the
pop-up form (?)
(also, i get an error, not in list message when the pop-up form opens -but I
really haven't looked into this...)

ANY suggestions wouldbe greatly appreciated

as always, thanks in advance
mark
 
D

DStegon via AccessMonster.com

change this to just

strNewManufacturer = Me.OpenArgs 'args come over as a string so I am assuming
your variable is of type String

Private Sub Form_Open(Cancel As Integer)
strNewManufacturer = Forms!FixtureCataloges.OpenArgs
Me.txtManufacturerName = strNewManufacturer
End Sub
 
S

Stuart McCall

Mark Kubicki said:
I am trying to pass a value to a pop-up form (without success)

on the main form, I have this code:

Private Sub Manufacturer_NotInList(NewData As String, Response As
Integer)
On Error GoTo Err_Manufacturer_NotInList

' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub

' Confirm that the user wants to add the new manufacturer.
Msg = "The manufacturer: " & NewData & " is not in the Master
Database." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
' If the user chose not to add the manufacturer, set the
Response
' argument to suppress an error message and undo changes.
Response = acDataErrContinue
MsgBox "Please try again."
Else
stDocName = "frmManufacturer_PopUp"
DoCmd.OpenForm stDocName, acNormal, , , acReadOnly, , NewData
Response = acDataErrAdded
End If

--------------------------------------
on the pop-up form I have this code:

Private Sub Form_Open(Cancel As Integer)
strNewManufacturer = Forms!FixtureCataloges.OpenArgs
Me.txtManufacturerName = strNewManufacturer
End Sub

but the result is not the value I want,but the name of a control on the
pop-up form (?)
(also, i get an error, not in list message when the pop-up form opens -but
I really haven't looked into this...)

ANY suggestions wouldbe greatly appreciated

as always, thanks in advance
mark

Move the line:

Response = acDataErrAdded

to precede the DoCmd.OpenForm line. That should supress the error message.

Then, in your popup form's Load event (rather than its Open event), include
the code:

Me.txtManufacturerName = Me.OpenArgs
 
D

DStegon via AccessMonster.com

Then, in your popup form's Load event (rather than its Open event), include
the code:

Me.txtManufacturerName = Me.OpenArgs

Good catch... oooppppsss !!!
 

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

Similar Threads


Top