Hello,
I would like to ask for the kind help of the community, to figure out the problem I am stuck at.
I would like to run a query with a button click. Said button is on a form, from where I would like to access a new form. The second form would get the data form the formerly mentioned query. The query is quite simple, it contains all records from two joined tables.
This is the code for the first form, where the button is:
Private Sub editSubBtn_Click()
Dim prevCtrl As Control
Set prevCtrl = Screen.PreviousControl
If prevCtrl.Name <> "frm Sub Szövet" Then
Exit Sub
End If
Dim tempReceiveDate As TempVar
TempVars!tempReceiveDate = Me.Átvétel_dátuma.Value
DoCmd.OpenForm "frm Szovet Edit", OpenArgs:=subNo 'subNo is defined as: Public subNo As Long, at the very top of my code
End Sub
On the second form:
Private Sub Form_Open(Cancel As Integer)
Me.AllowEdits = True
Me.AllowAdditions = False
If Nz(Me.OpenArgs) = 0 Then
Me.RecordSource = "qry_SzovetTarolas"
Else
Me.RecordSource = "SELECT qry_SzovetTarolas.* FROM qry_SzovetTarolas WHERE ((tblSzovet.[Azonosító])= 'Me.OpenArgs' );"
End If
End Sub
The bold part is where I get most of my error messages... Usually it is data type mismatch, as tblSzovet.[Azonosító] is the PK, and AutoNumber and the OpenArgs I want to pass should also be an integer. However, if I leave the ' ' then a pop-up window appears at the end of running, asking for a value to Me.OpenArgs. Even if I give it a number then the whole system stops, like it stuck in a loop.
I know this might be a very basic problem, but I would appreciate any help in solving it.
Thanks in advance,
Regina
I would like to ask for the kind help of the community, to figure out the problem I am stuck at.
I would like to run a query with a button click. Said button is on a form, from where I would like to access a new form. The second form would get the data form the formerly mentioned query. The query is quite simple, it contains all records from two joined tables.
This is the code for the first form, where the button is:
Private Sub editSubBtn_Click()
Dim prevCtrl As Control
Set prevCtrl = Screen.PreviousControl
If prevCtrl.Name <> "frm Sub Szövet" Then
Exit Sub
End If
Dim tempReceiveDate As TempVar
TempVars!tempReceiveDate = Me.Átvétel_dátuma.Value
DoCmd.OpenForm "frm Szovet Edit", OpenArgs:=subNo 'subNo is defined as: Public subNo As Long, at the very top of my code
End Sub
On the second form:
Private Sub Form_Open(Cancel As Integer)
Me.AllowEdits = True
Me.AllowAdditions = False
If Nz(Me.OpenArgs) = 0 Then
Me.RecordSource = "qry_SzovetTarolas"
Else
Me.RecordSource = "SELECT qry_SzovetTarolas.* FROM qry_SzovetTarolas WHERE ((tblSzovet.[Azonosító])= 'Me.OpenArgs' );"
End If
End Sub
The bold part is where I get most of my error messages... Usually it is data type mismatch, as tblSzovet.[Azonosító] is the PK, and AutoNumber and the OpenArgs I want to pass should also be an integer. However, if I leave the ' ' then a pop-up window appears at the end of running, asking for a value to Me.OpenArgs. Even if I give it a number then the whole system stops, like it stuck in a loop.
I know this might be a very basic problem, but I would appreciate any help in solving it.
Thanks in advance,
Regina