I have a form which requires an office name(cbobox). I want it required.
I took a function from the MS resource scheduler which allows one to double click on that field and enter an office where it doesn't already exist. This part works.
If I tab past "Office" when I first enter the form, it allows it (I don't want it to). If I double click to add an office (but don't & just exit that form) When it returns to the main form it requires the "Office" be entered.
I want it to require the office, whether they dblclick & add a new office, or just try to tab by it initially.
The code is:
Private Sub Office_NotInList(NewData As String, Response As Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
Private Sub Office_Exit(Cancel As Integer)
'Me.Office.Requery
If IsNull(Me![Office]) Or (Me!Office = "") Then
MsgBox "Office Required"
Cancel = True
End If
End Sub
Private Sub Office_DblClick(Cancel As Integer)
On Error GoTo Err_Office_DblClick
Dim lngOffice As Long
If IsNull(Me![Office]) Then
Me![Office].Text = ""
Else
lngOffice = Me![Office]
Me![Office] = Null
End If
DoCmd.OpenForm "Office", , , , , acDialog, "GotoNew"
Me![Office].Requery
If lngOffice <> 0 Then Me![Office] = lngOffice
Forms!frmScheduleRequest!Office = Me![Office]
Exit_Office_DblClick:
Exit Sub
Err_Office_DblClick:
MsgBox Err.Description
Resume Exit_Office_DblClick
End Sub
The Office form has:
Private Sub Form_Load()
If Me.OpenArgs = "GotoNew" And Not IsNull(Me![Office]) Then
DoCmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
End If
End Sub
Can someone Help me understand this?
Thanks,
Tamra
I took a function from the MS resource scheduler which allows one to double click on that field and enter an office where it doesn't already exist. This part works.
If I tab past "Office" when I first enter the form, it allows it (I don't want it to). If I double click to add an office (but don't & just exit that form) When it returns to the main form it requires the "Office" be entered.
I want it to require the office, whether they dblclick & add a new office, or just try to tab by it initially.
The code is:
Private Sub Office_NotInList(NewData As String, Response As Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
Private Sub Office_Exit(Cancel As Integer)
'Me.Office.Requery
If IsNull(Me![Office]) Or (Me!Office = "") Then
MsgBox "Office Required"
Cancel = True
End If
End Sub
Private Sub Office_DblClick(Cancel As Integer)
On Error GoTo Err_Office_DblClick
Dim lngOffice As Long
If IsNull(Me![Office]) Then
Me![Office].Text = ""
Else
lngOffice = Me![Office]
Me![Office] = Null
End If
DoCmd.OpenForm "Office", , , , , acDialog, "GotoNew"
Me![Office].Requery
If lngOffice <> 0 Then Me![Office] = lngOffice
Forms!frmScheduleRequest!Office = Me![Office]
Exit_Office_DblClick:
Exit Sub
Err_Office_DblClick:
MsgBox Err.Description
Resume Exit_Office_DblClick
End Sub
The Office form has:
Private Sub Form_Load()
If Me.OpenArgs = "GotoNew" And Not IsNull(Me![Office]) Then
DoCmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
End If
End Sub
Can someone Help me understand this?
Thanks,
Tamra