datacontrol
Registered User.
- Local time
- Today, 06:24
- Joined
- Jul 16, 2003
- Messages
- 142
here is the situation.....
I have this field on a form that users key into and when the click apply, the record is stored in a table. Sometimes they will not need to use this particular field.
As it is now, if they leave it blank, an error will occur. The filed is a short date field, I have the table and the form input box formatted as such.
Basically, I want to have a radio button that turns this on/off and then the user can fill out the field if needed.
Code:
Option Compare Database
Option Explicit
Private Sub apply_Click()
If IsNull(Me!rr) Then
MsgBox "You must place values in all fields."
ElseIf IsNull(Me!rc) Then
MsgBox "You must place values in all fields."
ElseIf IsNull(Me!time) Then
MsgBox "You must place values in all fields."
Else
DoCmd.RunSQL "INSERT INTO tbldtc(tbldtc_date, tbldtc_user, tbldtc_num_req_rec, tbldtc_num_req_pro, tbldtc_time, tbldtc_oldest_date) VALUES ('" & Me.date & "','" & Me.user & "','" & Me.rr & "','" & Me.rc & "','" & Me.time & "','" & Me.old & "')"
DoCmd.Close
MsgBox "Your data has been saved."
Exit Sub
End If
End Sub
Private Sub Command24_Click()
DoCmd.Close
End Sub
Private Sub Form_Open(Cancel As Integer)
SetFocus
End Sub
I have this field on a form that users key into and when the click apply, the record is stored in a table. Sometimes they will not need to use this particular field.
As it is now, if they leave it blank, an error will occur. The filed is a short date field, I have the table and the form input box formatted as such.
Basically, I want to have a radio button that turns this on/off and then the user can fill out the field if needed.
Code:
Option Compare Database
Option Explicit
Private Sub apply_Click()
If IsNull(Me!rr) Then
MsgBox "You must place values in all fields."
ElseIf IsNull(Me!rc) Then
MsgBox "You must place values in all fields."
ElseIf IsNull(Me!time) Then
MsgBox "You must place values in all fields."
Else
DoCmd.RunSQL "INSERT INTO tbldtc(tbldtc_date, tbldtc_user, tbldtc_num_req_rec, tbldtc_num_req_pro, tbldtc_time, tbldtc_oldest_date) VALUES ('" & Me.date & "','" & Me.user & "','" & Me.rr & "','" & Me.rc & "','" & Me.time & "','" & Me.old & "')"
DoCmd.Close
MsgBox "Your data has been saved."
Exit Sub
End If
End Sub
Private Sub Command24_Click()
DoCmd.Close
End Sub
Private Sub Form_Open(Cancel As Integer)
SetFocus
End Sub