right, since i changed to the DAO.Recordset i've got this error message:
Run-time error 3315
Field '***' cannot be a zero-length string
where *** is the name of what ever field is next. I've got error messages for required fields left empty, and no other fields are 'required' in either my form or table.
below is ALL the code for the form, in bold is the line which is highlighted when debug is selected.
if all the fields are filled in then the form submits.
thank you!
Run-time error 3315
Field '***' cannot be a zero-length string
where *** is the name of what ever field is next. I've got error messages for required fields left empty, and no other fields are 'required' in either my form or table.
below is ALL the code for the form, in bold is the line which is highlighted when debug is selected.
Option Compare Database
Dim Rsttable As DAO.Recordset
Private Sub PostCode_Exit(Cancel As Integer)
postcode = VBA.UCase(postcode)
End Sub
Private Sub firstname_Exit(Cancel As Integer)
Dim t As String
t = firstname.Text
If t <> "" Then
Mid$(t, 1, 1) = UCase$(Mid$(t, 1, 1))
firstname.Text = t
End If
End Sub
Private Sub surname_Exit(Cancel As Integer)
Dim t As String
t = surname.Text
If t <> "" Then
Mid$(t, 1, 1) = UCase$(Mid$(t, 1, 1))
surname.Text = t
End If
End Sub
Sub address1_Exit(Cancel As Integer)
Dim t As String
t = address1.Text ' Put contents of text box
' into a string variable.
If t <> "" Then
Mid$(t, 1, 1) = UCase$(Mid$(t, 1, 1))
For i = 1 To Len(t) - 1
If Mid$(t, i, 1) = " " Then
' Capitalize words preceded by a space:
Mid$(t, i + 1, 1) = UCase$(Mid$(t, i + 1, 1))
End If
Next
address1.Text = t
End If
End Sub
Sub address2_Exit(Cancel As Integer)
Dim t As String
t = Address2.Text ' Put contents of text box
' into a string variable.
If t <> "" Then
Mid$(t, 1, 1) = UCase$(Mid$(t, 1, 1))
For i = 1 To Len(t) - 1
If Mid$(t, i, 1) = " " Then
' Capitalize words preceded by a space:
Mid$(t, i + 1, 1) = UCase$(Mid$(t, i + 1, 1))
End If
Next
Address2.Text = t
End If
End Sub
Sub address3_Exit(Cancel As Integer)
Dim t As String
t = Address3.Text ' Put contents of text box
' into a string variable.
If t <> "" Then
Mid$(t, 1, 1) = UCase$(Mid$(t, 1, 1))
For i = 1 To Len(t) - 1
If Mid$(t, i, 1) = " " Then
' Capitalize words preceded by a space:
Mid$(t, i + 1, 1) = UCase$(Mid$(t, i + 1, 1))
End If
Next
Address3.Text = t
End If
End Sub
Private Sub cmdadd_Click()
If IsNull(firstname) = True Then
MsgBox "Please enter a First Name"
firstname.SetFocus
Else
If IsNull(surname) = True Then
MsgBox "Please enter a Last Name"
surname.SetFocus
Else
Set Rsttable = CurrentDb.OpenRecordset("tblScout", dbOpenDynaset)
Rsttable.AddNew
Rsttable!firstname = firstname
Rsttable!surname = surname
Rsttable!DOB = DOB
Rsttable!address1 = address1
Rsttable!Address2 = Address2
Rsttable!Address3 = Address3
Rsttable!postcode = postcode
Rsttable!phone1 = phone1
Rsttable!phone2 = phone2
Rsttable!email = email
Rsttable.Update
Rsttable.Close
MsgBox "" & firstname & " " & surname & " was successfully added."
firstname = ""
surname = ""
DOB = ""
address1 = ""
Address2 = ""
Address3 = ""
postcode = ""
phone1 = ""
phone2 = ""
email = ""
End If
End If
End Sub
if all the fields are filled in then the form submits.
thank you!