Emma said:
I tried to pass multiple parameters using a delimiter as follows:
In my first form. Job_Type is a combo box
Private Sub Job_Type_AfterUpdate()
Select Case Me!Job_Type
Case "New Contract"
DoCmd.GoToControl "Frame_Contract_Option"
Case "Rental"
MyOpenArgs_Rental = Me!Account_No(0) & "-" & Me!Account_No(1) & "-"
& Me!Account_No(4) & "-" & Me!Account_No(5) & "-" & Me!Account_No(6) & "-" &
Me!Account_No(7)
'Account No, Name, address 1, address 2, city, state, and zip
DoCmd.OpenForm "frm_Rental_Detail", acNormal, Qry_Rental_Detail, ,
acFormAdd, acWindowNormal, MyOpenArgs_Rental
Case "Evaluation"
DoCmd.OpenForm "frm_Eval_Detail", acNormal, Qry_Eval_Detail, ,
acFormAdd, acWindowNormal, Me!Account_No
Case Else
DoCmd.GoToControl "Rep_name"
End Select
End Sub
In my second form, I have the following code in the "OnLoad" event.
Private Sub Form_Load()
Me!Rental_Acct_No = Split(Me.OpenArgs, "-")(0)
Me!Rental_Acct_Name = Split(Me.OpenArgs, "-")(1)
Me!Rental_Acct_Address_1 = Split(Me.OpenArgs, "-")(2)
Me!Rental_Acct_Address_2 = Split(Me.OpenArgs, "-")(3)
Me!Rental_Acct_City = Split(Me.OpenArgs, "-")(4)
Me!Rental_Acct_State = Split(Me.OpenArgs, "-")(5)
Me!Rental_Acct_Zip = Split(Me.OpenArgs, "-")(6)
End Sub
I am getting the following error.
"Property let procedure not defined and property get procedure did not
return an object."
Why am I getting this error?
Thank you,
:
Emma,
In the Job_Type_AfterUpdate() code, you need to use the .Column() property.
Change the line
MyOpenArgs_Rental = Me!Account_No(0) & "-" & Me!Account_No(1) & "-" &
Me!Account_No(4) & "-" & Me!Account_No(5) & "-" & Me!Account_No(6) & "-" &
Me!Account_No(7)
to
MyOpenArgs_Rental = Me!Account_No.Column(0) & "-" & Me!Account_No.Column(1) &
"-" & Me!Account_No.Column(4) & "-" & Me!Account_No.Column(5) & "-" &
Me!Account_No.Column(6) & "-" & Me!Account_No.Column(7)
In the second form, change the Form_Load code to:
Private Sub Form_Load()
Dim MyOpenArgsArray
MyOpenArgsArray = Array(6)
MyOpenArgsArray = Split(MyOpenArgs_Rental, "-")
Me!Rental_Acct_No = MyOpenArgsArray(0)
Me!Rental_Acct_Name = MyOpenArgsArray(1)
Me!Rental_Acct_Address_1 = MyOpenArgsArray(2)
Me!Rental_Acct_Address_2 = MyOpenArgsArray(3)
Me!Rental_Acct_City = MyOpenArgsArray(4)
Me!Rental_Acct_State = MyOpenArgsArray(5)
Me!Rental_Acct_Zip = MyOpenArgsArray(6)
End Sub
The Split() function fills an array, so first you have to declare an array.
Then you can fill the controls from the array.
Not to argue with John Vinson, I would use the Load event. The order of events
for a form is (from Help)
Open -> Load -> Resize -> Activate -> Current
"The Open event occurs when a form is opened, but before the first record is
displayed."
"The Load event occurs when a form is opened and its records are displayed.
By running a macro or an event procedure when a form's Load event occurs, you
can specify default settings for controls, or display calculated data that
depends on the data in the form's records."
HTH