M
mma40
How can I feed my UserNumber from the Main form to new dataentry form?
Once I enter manually the UserNumber my LastName field automatically
fills in. Is there a way to feed it without manual input
Private Sub VisitEntry_Click()
On Error GoTo Err_VisitEntry_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "VisitEntry"
stLinkCriteria = "[UserNumber]=" & Me![UserNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_VisitEntry_Click:
Exit Sub
Err_VisitEntry_Click:
MsgBox Err.Description
Resume Exit_VisitEntry_Click
End Sub
Also after the update/save (via save button) and return to main form,
if I click this same button to add a new entry and it shows all the
subform records for this client.
Here is code using:
Private Sub SaveVisit_Click()
On Error GoTo Err_SaveVisit_Click
'save current record
If Me.Dirty Then Me.Dirty = False
'current record
Dim mRecordID As Long
mRecordID = Nz(Me.UserNumber)
DoCmd.OpenForm "Main", , , "[UserNumber] = " & Me!UserNumber
'Go back
Me.RecordsetClone.FindFirst "UserNumber = " & mRecordID
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
Exit_SaveVisit_Click:
Exit Sub
Err_SaveVisit_Click:
MsgBox Err.Description
Resume Exit_SaveVisit_Click
Once I enter manually the UserNumber my LastName field automatically
fills in. Is there a way to feed it without manual input
Private Sub VisitEntry_Click()
On Error GoTo Err_VisitEntry_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "VisitEntry"
stLinkCriteria = "[UserNumber]=" & Me![UserNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_VisitEntry_Click:
Exit Sub
Err_VisitEntry_Click:
MsgBox Err.Description
Resume Exit_VisitEntry_Click
End Sub
Also after the update/save (via save button) and return to main form,
if I click this same button to add a new entry and it shows all the
subform records for this client.
Here is code using:
Private Sub SaveVisit_Click()
On Error GoTo Err_SaveVisit_Click
'save current record
If Me.Dirty Then Me.Dirty = False
'current record
Dim mRecordID As Long
mRecordID = Nz(Me.UserNumber)
DoCmd.OpenForm "Main", , , "[UserNumber] = " & Me!UserNumber
'Go back
Me.RecordsetClone.FindFirst "UserNumber = " & mRecordID
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
Exit_SaveVisit_Click:
Exit Sub
Err_SaveVisit_Click:
MsgBox Err.Description
Resume Exit_SaveVisit_Click