accvbalearner
Registered User.
- Local time
- Yesterday, 18:23
- Joined
- Jan 3, 2013
- Messages
- 42
I am working on the data entry forms for a database. I'm confusing myself trying to ask the right question(s) so here goes...
I have three forms, Form1, Form2 & Form3. All are for entering data into tables.
Form1 and Form2 have a Facility Name Field ComboBox
Form3 is for adding New Facilities
The code below is in Form1 and Form2 to determine if the Facility entered by the user is in the list, if it isn't in the list then the user can choose to open Form3.
Form3 will let them enter a New Facility Name.
Now I think this is the right question:
How do I tell the cursor to return to the Facility name Field in the Form that caused Form3 to be opened in the first place?
If it were just one form causing the entry I think a DoCmd.OpenForm would work on the On Close Event of Form3. But it could be either Form1 or Form2 that caused Form3 to be opened.
Thanks in advance for any help you can provide.
Private Sub Facility_NotInList(NewData As String, Response As Integer)
Dim intReply As Integer
intReply = MsgBox("The Facility '" & NewData & "' is not in the list. Would you like to add?", vbYesNo)
If intReply = vbYes Then
' -- Open F12-NewFacilityEntry form in data entry mode, passing the new data as
' -- an OpenArg
DoCmd.OpenForm "F12-NewFacilityEntry", , , , acFormAdd, acDialog, NewData
'-- Record added, so cancel Access's default processing
Response = acDataErrAdded
Else
MsgBox "Please Select an item in the list."
'-- We have handled the error, so tell Access not to put up
'-- it's own default error
Response = acDataErrContinue
End If
End Sub
I have three forms, Form1, Form2 & Form3. All are for entering data into tables.
Form1 and Form2 have a Facility Name Field ComboBox
Form3 is for adding New Facilities
The code below is in Form1 and Form2 to determine if the Facility entered by the user is in the list, if it isn't in the list then the user can choose to open Form3.
Form3 will let them enter a New Facility Name.
Now I think this is the right question:
How do I tell the cursor to return to the Facility name Field in the Form that caused Form3 to be opened in the first place?
If it were just one form causing the entry I think a DoCmd.OpenForm would work on the On Close Event of Form3. But it could be either Form1 or Form2 that caused Form3 to be opened.
Thanks in advance for any help you can provide.
Private Sub Facility_NotInList(NewData As String, Response As Integer)
Dim intReply As Integer
intReply = MsgBox("The Facility '" & NewData & "' is not in the list. Would you like to add?", vbYesNo)
If intReply = vbYes Then
' -- Open F12-NewFacilityEntry form in data entry mode, passing the new data as
' -- an OpenArg
DoCmd.OpenForm "F12-NewFacilityEntry", , , , acFormAdd, acDialog, NewData
'-- Record added, so cancel Access's default processing
Response = acDataErrAdded
Else
MsgBox "Please Select an item in the list."
'-- We have handled the error, so tell Access not to put up
'-- it's own default error
Response = acDataErrContinue
End If
End Sub