Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
Old 06-02-2008, 08:04 AM   #1
str33ty
Registered User
 
Join Date: Jun 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
str33ty is on a distinguished road
Run time error 3315

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.

Quote:
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!

str33ty is offline   Reply With Quote
Old 06-02-2008, 09:04 AM   #2
str33ty
Registered User
 
Join Date: Jun 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
str33ty is on a distinguished road
hmm, works now!
str33ty is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Run time error '13' Type mismatch alant37 Modules & VBA 1 06-22-2005 06:32 AM
Run Time Error - No Value Given RichardH Modules & VBA 3 06-16-2005 04:17 AM
Run Time Error 2001 - What am I doing wrong? zeee Reports 0 01-06-2005 07:52 AM
Run Time Error after refreshing the form zeee Forms 0 01-06-2005 07:12 AM
Out of Memory - Run time error 7 linda sciallo Reports 0 11-15-2001 07:31 AM




All times are GMT -8. The time now is 01:18 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World