473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

I have a EOF error in vba code and not sure why.

1
Private Sub Add_new_button_Click()

DoCmd.SetWarnings False

Dim SQL As String
Dim fName As String
Dim lName As String
Dim fGroup As String
Dim Shift As String
Dim mNum As String
Dim hNum As String
Dim email As String
Dim position As String
Dim Notes As String

If IsNull([Staff First Name]) = True Then
MsgBox "*Staff First Name REQUIRED*"
Else
fName = [Staff First Name]

If IsNull([Staff Last Name]) = True Then
MsgBox "*Staff Last Name REQUIRED*"
Else
lName = [Staff Last Name]

If IsNull([Staff Email]) = True Then
MsgBox "*Staff Email REQUIRED*"
Else
email = [Staff Email]

If IsNull([Staff Position]) = True Then
position = "null"
Else
position = [Staff Position]

If IsNull([Facillity Group]) = True Then
MsgBox "*The Program Is REQUIRED*"
Else
fGroup = [Facillity Group]

If IsNull([Notes]) = True Then
Notes = "null"
Else
Notes = [Notes]

If IsNull([Staff Mobile Number]) = True Then
mNum = "null"
Else
mNum = [Staff Mobile Number]

If IsNull([Staff Home Number]) = True Then
hNum = "null"
Else
hNum = [Staff Home Number]

'The part in question starts from here-->
SQL = "[Staff First Name]='" & fName & "' AND [Staff Last Name]='" & lName & "' & _
[Staff Mobile Number]= " & mNum & " And [Staff Home Number] = '" & hNum & "' & _
[Staff Email] = '" & email & "' And [Staff Position] = '" & position & "' & _
[Facillity Group] = '" & fGroup & "' And [Notes] ='" & Notes & "' "
'to here--->
If (DCount("*", "Staff", SQL) > 0) Then
MsgBox "Duplicate Information! Staff already in System."
Else
SQL = "Insert INTO Staff([Staff First Name], [Staff Last Name], [Staff Mobile Number], [Staff Home Number], [Staff Email], [Staff Position], [Facility Group], [Notes])" & _
"VALUES ('" & fName & "' , '" & lName & "', '" & mNum & "','" & hNum & "', '" & email & "', '" & position & "','" & fGroup & "', '" & Notes & "')"


DoCmd.RunSQL SQL

MsgBox "Insert of Staff Complete"
DoCmd.GoToRecord , [Staff Form], acNewRec

End If
End If
End If
End If
End If
End If
End If
End If
End Sub
Aug 8 '12 #1
2 1808
twinnyfo
3,653 Expert Mod 2GB
Troy,

First, a reminder to include your code within the Code tags, please.

Second, where in your code is the EOF error tripping?

Thanks!
Aug 8 '12 #2
zmbd
5,501 Expert Mod 4TB
First: You must use the [code][/code] tags.
http://bytes.com/topic/access/answer...-posting-forum

Second: Where in the code does your error happen... we simply can not compile your code on our PC and run it.

Third:
Expand|Select|Wrap|Line Numbers
  1. 'The part in question starts from here-->
  2. SQL = "[Staff First Name]='" & fName & "' AND [Staff Last Name]='" & lName & "' & _
  3. [Staff Mobile Number]= " & mNum & " And [Staff Home Number] = '" & hNum & "' & _
  4. [Staff Email] = '" & email & "' And [Staff Position] = '" & position & "' & _
  5. [Facillity Group] = '" & fGroup & "' And [Notes] ='" & Notes & "' "
  6. 'to here--->
Please post the resulting string...
Add a "Stop" command following this string.
When the execution stops, in the immediate (debug) window type: "?SQL" (without the quotes) Post back the string.

Fourth: My guess is that your failing on the move to the new record... change that move to aclast.

-z
Aug 8 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: SK | last post by:
Hi all, I am dealing with sockets in my code. I open them like - System.Net.IPAddress remoteIPAddress = System.Net.IPAddress.Parse (szIPSelected); System.Net.IPEndPoint remoteEndPoint = new...
2
by: Roger Wang | last post by:
HELP!!!! We have got a W2k server running IIS5 with .NET framework 1.1 and .NET framework SP1. All ASP.NET applications cannot run on this box. It all returned with the same error: ...
1
by: jfleeson | last post by:
I'm getting the following error after installing the .NET Framework 1.1. Do anyone have a solution? "aspnet_wp.exe could not be started. The error code for the failure is 80070545. This error...
2
by: hansiman | last post by:
I'm wondering how best to present exception messages to a user. In a try catch I catch an OleDb.OleDbException. The error could be a COLUMN REFERENCE constraint error (by a deletion attempt). ...
2
by: Madhu | last post by:
Hello All, I am getting the below error message when I am trying to connect from client to remote database server installed on Linux. DB2 UDB ESE database is running on a trail version on Linux...
3
by: ralphdepping | last post by:
Trying to get moinmoin wiki working on Windows 2000 using IIS and python. I get the following error when trying to view the start page after insalling moinmoin and python - key error seems to be...
1
by: Larry Epn | last post by:
I've created a project from Microsoft's "club.vsi". I don't want inline code so I've separated all aspx and ascx pages into code-behind pages. I'm compiling the project and continue to get this...
2
by: cboccio | last post by:
Hi people !! I need some help about this error... I have a DB2 databese Version 8 with a Power Biulder application. In my environment I have 3 databases and the application connect in a...
11
by: fniles | last post by:
We can not register an ActiveX control on our Vista 32 bit machine. When we do regsvr32 c:\windows\system32\citcp.ocx (this is a 3rd party ActiveX control), we got an error: citcp.ocx was loaded...
0
by: t0rmed | last post by:
I am currently creating my project for visual basic, which is particularly a database. However, error code 3021 shows up when I click delete even though I do not have a database. How could I solve...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.