Hi all,
I am rather new in the world of access and a search though this website did not give any results. The problem is as follows.
background:
I have a drop-down box with user names in it coming from a table. In time more user will be working with the database and therefore I added an 'add' button. Clicking the button will result is a new form called 'frm_add_user'.
On the 'frm_add_user' the are two fields; Username and abbreviation. and a 'ok' button.
Problem:
when the OK button is clicked, the entered data should be added to a table called 'tbl_user'. But if one of the fields is left empty it should give a error message and not enter the date to the table.
I have tried many things like a before update event and many more. Whatever I do the result is the same and the table is updated with blank fields.
I hope somebody can help me with this.
Kind regards
Wouter
Code:
'Private Sub frm_newuser_beforeUpdate(Cancel As Integer)
'check whether all field are filled
If IsNull(Me.Username) Then
MsgBox "user name is required"
If IsNull(Me.abbreviation) Then
MsgBox "abbreviation is required. Maximum is 4 Characters"
cancel = True
End If
DoCmd.SetWarnings True
GoTo ExitUpdate:
End If
End Sub
I am rather new in the world of access and a search though this website did not give any results. The problem is as follows.
background:
I have a drop-down box with user names in it coming from a table. In time more user will be working with the database and therefore I added an 'add' button. Clicking the button will result is a new form called 'frm_add_user'.
On the 'frm_add_user' the are two fields; Username and abbreviation. and a 'ok' button.
Problem:
when the OK button is clicked, the entered data should be added to a table called 'tbl_user'. But if one of the fields is left empty it should give a error message and not enter the date to the table.
I have tried many things like a before update event and many more. Whatever I do the result is the same and the table is updated with blank fields.
I hope somebody can help me with this.
Kind regards
Wouter
Code:
'Private Sub frm_newuser_beforeUpdate(Cancel As Integer)
'check whether all field are filled
If IsNull(Me.Username) Then
MsgBox "user name is required"
If IsNull(Me.abbreviation) Then
MsgBox "abbreviation is required. Maximum is 4 Characters"
cancel = True
End If
DoCmd.SetWarnings True
GoTo ExitUpdate:
End If
End Sub