values passed in OpenArgs not displaying in text boxes on called f

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I am trying to pass values from one form to another via OpenArgs. In Case 1
the user selects the "Int" Option and frm_tbl_Contracts_Int is supposed to
pop open with values from the calling form poplulating the called form as
follows:

frm_tbl_MasterJobs!Job_ID populating frm_tbl_Contracts_Int!fk_Job_Id

frm_tbl_MasterJobs!cbo_Account_No populating
frm_tbl_Contracts_Int!txt_Account_No

frm_tbl_MasterJobs!cbo_Account_No.Column(1) populating
frm_tbl_Contracts_Int!Contract_Account_Name

The code on the Main form (calling form) is as follows:

Private Sub Frame_Contract_Type_AfterUpdate()

Dim MyOpenArgs As String

MyOpenArgs = Me!Job_ID & "," & Me!cbo_Account_No & "," &
Me!cbo_Account_No.Column(1)

Select Case Form_frm_Tbl_Master_Jobs!Frame_Contract_Type
Case 1
DoCmd.OpenForm "Frm_Tbl_Contracts_Int", , , , acFormAdd, , MyOpenArgs
Case 2
DoCmd.OpenForm "Frm_Tbl_Contracts_Biopsy", , , , acFormAdd
Case Else
DoCmd.GoToControl "Comments"
End Select

End Sub

The code in the called form is as follows:

Private Sub Form_Open(Cancel As Integer)

Dim txt_Account_No As String
Dim FK_Job_ID As Integer
Dim Contract_Account_Name As String

If IsNull(OpenArgs) = False Then

FK_Job_ID = Split(OpenArgs, ",")(0)
txt_Account_No = Split(OpenArgs, ",")(1)
Contract_Account_Name = Split(OpenArgs, ",")(2)

End If

End Sub

When I look at the variable MyOpenArgs using a msgbox in the calling form my
values are there.

When I use a msgbox in my called form to look at each of the individual
variable values fk_Job_Id, txt_Account_No, and Contract_Account_Name they are
there are coming over. But why are they not appearing in my text boxes?
 
Hi All,

I figured it out!!!! I am so happy. The problem arose from the name of my
text boxes. The name had to be different than the control source. I don't
know why by it did. Once I changed the name of the text boxes and reflected
that change in my code, the values appeared in the text boxes.

Thank you all for your help - - this has been a challenging experience and I
have learned alot!

Now on to the next challenge!
 
Emma,

It is common programming practice to change the names of controls so that
they can be easily interpreted, rather than having a control whose name
matches the underlying field name. This practice also applies to variables
and other objects reference in your code. You can find a number of sites on
the web that display some of the common ones. This one
(http://www.visibleprogress.com/vb_naming_conventions.htm) is the first one
I came to when I did a google search on: Visual Basic naming conventions

HTH
Dale
 
Back
Top