I am trying to have users enter information into 3 unbound fields on a form and click a button to do the following:
Check to ensure all fields are filled out. In one is not filled out then return an error and end.
Check to ensure that the data in the MEMNAME field on the form does not appear in the MBR_NAME field of the ROSTER table.
If the name is duplicated on the table then return an error and end. If not then add the data in all 3 fields as a new record in the ROSTER table and end.
I am getting an error when I click the button and I am unsure of how I can fix it.
Private Sub Command12_Click()
'--- only process Save if there is data in all fields
If IsNull(MEMNAME) Then
MsgBox "Please enter a character name."
If IsNull(CLASS) Then
MsgBox "Please enter a class."
If IsNull(ROLE) Then
MsgBox "Please enter a role."
Dim rst As Recordset
'--- use the primary keys to find the record
'--- if it is a new record, this will find no records
Set rst = CurrentDb.OpenRecordset("select * from ROSTER where MBR_NAME=" & MEMNAME & ")
If chkNew = True Then '--- do we add a new record or return an error
MsgBox "Member is already on the roster."
'--- transfer data from text boxes to table fields
rst!MBR_NAME = MEMNAME
rst!MBR_CLASS = CLASS
rst!MBR_ROLE = ROLE
rst.Update '--- save the record
rst.Close '--- close the recordset
Set rst = Nothing '--- reclaim the memory the recordset was using