PDA

View Full Version : VBA form not passing values



Nwtech75
08-14-2018, 11:54 PM
Hi All, first post in a while, I've been really busy.

I'm missing something simple with an Access project.

I have two forms. I am attempting to pass two pieces of data from the main form to the new pop up form. The code looks right and I'm either missing something on the delivery or the deployment, but whichever it is, the correct information is not populating.

On the signoff form I need two vital parts of information. The Logpg and the tail number or reg in this case. Clicking on the 8130 button is supposed to copy both pieces and deliver them to the new open form. I can get the form to open but it won't pass the data



'This is from the sign off form
Private Sub btn_8130_Click()

Dim lp As String
Dim reg As String

lp = Me.Logpg.Value
reg = Me.tail.Value

DoCmd.OpenForm "frm_8130", acNormal, , , acFormAdd, acWindowNormal, "lp ; reg"

End Sub


'This is the second form that is opened

Private Sub Form_Load(Canel As Integer)


Dim Args As String


If Not IsNull(Me.OpenArgs) Then
Args = Split(Me.OpenArgs, ";")
Me.Logpg = argstrg(0) 'This should be the log page passed from the sign-off form
Me.reg = argstrg(1) 'This should be the tail number passed from the sign 0ff form
End If


End Sub




I'm not sure what I'm doing wrong and would appreciate and direction anyone can throw me.

Thanks

OBP
08-15-2018, 01:00 AM
To pass data using a variable you should declare the variable as a "Public variable".
Create a Module and add a line like this using your variables

Public myuserid As Integer

That will allow those variables to be used anywhere in the database.