I am trying to open new form (which is bound to a table) from another form ( in which i have code as follows).
Private Sub Edit_Reading_Click()
On Error GoTo Err_Edit_Reading_Click
Dim stDocName As String
'Dim stLinkCriteria As String
'Dim db As Database
'Dim rs As Recordset
Dim strngQry As String
stDocName = "Edit Reading"
metrNumbr = [Forms]![Get Meter Reading]![Meter Number]
uhoh = MsgBox("The meter number you have Entered is: " & metrNumbr)
DoCmd.Close acForm, "Edit Reading"
'strngQry = "SELECT * FROM [tblMeterInformation] WHERE [MeterNumber] = " & Me![Meter Number]
'strngQry = "[MeterNumber] = " & [Forms]![Get Meter Reading]![Meter Number]
DoCmd.OpenForm stDocName, , , metrNumbr
Exit_Edit_Reading_Click:
Exit Sub
Err_Edit_Reading_Click:
MsgBox Err.Description
Resume Exit_Edit_Reading_Click
End Sub
++++++++++++++++++++++++++++++++++++++++++++++
upon running this query with am existing Meternumber in the table. it is printing the message " No records exists". This message was written by me in the new form On_load function.
The code for this as bellow.
Private Sub Form_Load()
MeterNumber1 = [Forms]![Get Meter Reading]![Meter Number]
uhoh = MsgBox("The meter number you have Entered is: " & MeterNumber1)
If DCount("[Meter Number]", "Edit Data") = 0 Then
uhoh = MsgBox("This meter number: " & MeterNumber1 & " does not currently hold data within this database. Do you wish to add data to this meter number?", vbYesNo, "Missing Meter Number!")
If uhoh = vbYes Then
DoCmd.Close acForm, "Get Meter Reading"
DoCmd.Close acForm, "Edit Reading"
DoCmd.OpenForm "Add Meter Readings1", acNormal
[Forms]![Add Meter Readings1]![txtMtrNum] = MeterNumber1
Else
DoCmd.Close acForm, "Edit Reading"
DoCmd.OpenForm "Get Meter Reading", acNormal
End If
Else
DoCmd.Close acForm, "Get Meter Reading"
End If
End Sub
At some point i made it to work...but later i changed the query to make it multifield query and i lost track of it totally.
Question is: can any body help me where i am overlooking?
Thanks
mallinarc
Private Sub Edit_Reading_Click()
On Error GoTo Err_Edit_Reading_Click
Dim stDocName As String
'Dim stLinkCriteria As String
'Dim db As Database
'Dim rs As Recordset
Dim strngQry As String
stDocName = "Edit Reading"
metrNumbr = [Forms]![Get Meter Reading]![Meter Number]
uhoh = MsgBox("The meter number you have Entered is: " & metrNumbr)
DoCmd.Close acForm, "Edit Reading"
'strngQry = "SELECT * FROM [tblMeterInformation] WHERE [MeterNumber] = " & Me![Meter Number]
'strngQry = "[MeterNumber] = " & [Forms]![Get Meter Reading]![Meter Number]
DoCmd.OpenForm stDocName, , , metrNumbr
Exit_Edit_Reading_Click:
Exit Sub
Err_Edit_Reading_Click:
MsgBox Err.Description
Resume Exit_Edit_Reading_Click
End Sub
++++++++++++++++++++++++++++++++++++++++++++++
upon running this query with am existing Meternumber in the table. it is printing the message " No records exists". This message was written by me in the new form On_load function.
The code for this as bellow.
Private Sub Form_Load()
MeterNumber1 = [Forms]![Get Meter Reading]![Meter Number]
uhoh = MsgBox("The meter number you have Entered is: " & MeterNumber1)
If DCount("[Meter Number]", "Edit Data") = 0 Then
uhoh = MsgBox("This meter number: " & MeterNumber1 & " does not currently hold data within this database. Do you wish to add data to this meter number?", vbYesNo, "Missing Meter Number!")
If uhoh = vbYes Then
DoCmd.Close acForm, "Get Meter Reading"
DoCmd.Close acForm, "Edit Reading"
DoCmd.OpenForm "Add Meter Readings1", acNormal
[Forms]![Add Meter Readings1]![txtMtrNum] = MeterNumber1
Else
DoCmd.Close acForm, "Edit Reading"
DoCmd.OpenForm "Get Meter Reading", acNormal
End If
Else
DoCmd.Close acForm, "Get Meter Reading"
End If
End Sub
At some point i made it to work...but later i changed the query to make it multifield query and i lost track of it totally.
Question is: can any body help me where i am overlooking?
Thanks
mallinarc