Номер ошибки: | Ошибка 3134 | |
Название ошибки: | Microsoft Access Error 3134 | |
Описание ошибки: | Syntax error in INSERT INTO statement. | |
Разработчик: | Microsoft Corporation | |
Программное обеспечение: | Microsoft Access | |
Относится к: | Windows XP, Vista, 7, 8, 10, 11 |
Основы «Microsoft Access Error 3134»
Эксперты обычно называют «Microsoft Access Error 3134» «ошибкой времени выполнения». Когда дело доходит до программного обеспечения, как Microsoft Access, инженеры могут использовать различные инструменты, чтобы попытаться сорвать эти ошибки как можно скорее. К сожалению, инженеры являются людьми и часто могут делать ошибки во время тестирования, отсутствует ошибка 3134.
После установки программного обеспечения может появиться сообщение об ошибке «Syntax error in INSERT INTO statement.». Сообщение об этой ошибке 3134 позволит разработчикам обновить свое приложение и исправить любые ошибки, которые могут вызвать его. Затем Microsoft Corporation нужно будет исправить эти ошибки в главном исходном коде и предоставить модифицированную версию для загрузки. В результате разработчик может использовать пакеты обновлений для Microsoft Access, доступные с их веб-сайта (или автоматическую загрузку), чтобы устранить эти ошибки 3134 проблемы и другие ошибки.
Почему происходит ошибка времени выполнения 3134?
В большинстве случаев вы увидите «Microsoft Access Error 3134» во время загрузки Microsoft Access. Проанализируем некоторые из наиболее распространенных причин ошибок ошибки 3134 во время выполнения:
Ошибка 3134 Crash — это очень популярная ошибка выполнения ошибки 3134, которая приводит к завершению работы всей программы. Это возникает, когда Microsoft Access не реагирует на ввод должным образом или не знает, какой вывод требуется взамен.
Утечка памяти «Microsoft Access Error 3134» — последствия утечки памяти Microsoft Access связаны с неисправной операционной системой. Это может быть вызвано неправильной конфигурацией программного обеспечения Microsoft Corporation или когда одна команда запускает цикл, который не может быть завершен.
Error 3134 Logic Error — Ошибка программной логики возникает, когда, несмотря на точный ввод от пользователя, производится неверный вывод. Когда точность исходного кода Microsoft Corporation низкая, он обычно становится источником ошибок.
Повреждение, отсутствие или удаление файлов Microsoft Access Error 3134 может привести к ошибкам Microsoft Access. Возникновение подобных проблем является раздражающим фактором, однако их легко устранить, заменив файл Microsoft Corporation, из-за которого возникает проблема. В качестве дополнительного шага по устранению неполадок мы настоятельно рекомендуем очистить все пути к неверным файлам и ссылки на расширения файлов Microsoft Corporation, которые могут способствовать возникновению такого рода ошибок, связанных с Microsoft Access Error 3134.
Классические проблемы Microsoft Access Error 3134
Типичные ошибки Microsoft Access Error 3134, возникающие в Microsoft Access для Windows:
- «Ошибка программы Microsoft Access Error 3134. «
- «Ошибка программного обеспечения Win32: Microsoft Access Error 3134»
- «Microsoft Access Error 3134 столкнулся с проблемой и закроется. «
- «Microsoft Access Error 3134 не может быть найден. «
- «Отсутствует файл Microsoft Access Error 3134.»
- «Ошибка запуска программы: Microsoft Access Error 3134.»
- «Microsoft Access Error 3134 не работает. «
- «Отказ Microsoft Access Error 3134.»
- «Microsoft Access Error 3134: путь приложения является ошибкой. «
Проблемы Microsoft Access Error 3134 с участием Microsoft Accesss возникают во время установки, при запуске или завершении работы программного обеспечения, связанного с Microsoft Access Error 3134, или во время процесса установки Windows. Важно отметить, когда возникают проблемы Microsoft Access Error 3134, так как это помогает устранять проблемы Microsoft Access (и сообщать в Microsoft Corporation).
Эпицентры Microsoft Access Error 3134 Головные боли
Проблемы Microsoft Access Error 3134 вызваны поврежденным или отсутствующим Microsoft Access Error 3134, недопустимыми ключами реестра, связанными с Microsoft Access, или вредоносным ПО.
В частности, проблемы Microsoft Access Error 3134 возникают через:
- Поврежденная или недопустимая запись реестра Microsoft Access Error 3134.
- Вредоносные программы заразили Microsoft Access Error 3134, создавая повреждение.
- Другая программа злонамеренно или по ошибке удалила файлы, связанные с Microsoft Access Error 3134.
- Другая программа, конфликтующая с Microsoft Access Error 3134 или другой общей ссылкой Microsoft Access.
- Microsoft Access (Microsoft Access Error 3134) поврежден во время загрузки или установки.
Продукт Solvusoft
Загрузка
WinThruster 2022 — Проверьте свой компьютер на наличие ошибок.
Совместима с Windows 2000, XP, Vista, 7, 8, 10 и 11
Установить необязательные продукты — WinThruster (Solvusoft) | Лицензия | Политика защиты личных сведений | Условия | Удаление
How to fix the Runtime Code 3134 Microsoft Access Error 3134
This article features error number Code 3134, commonly known as Microsoft Access Error 3134 described as Syntax error in INSERT INTO statement.
About Runtime Code 3134
Runtime Code 3134 happens when Microsoft Access fails or crashes whilst it’s running, hence its name. It doesn’t necessarily mean that the code was corrupt in some way, but just that it did not work during its run-time. This kind of error will appear as an annoying notification on your screen unless handled and corrected. Here are symptoms, causes and ways to troubleshoot the problem.
Definitions (Beta)
Here we list some definitions for the words contained in your error, in an attempt to help you understand your problem. This is a work in progress, so sometimes we might define the word incorrectly, so feel free to skip this section!
- Access — DO NOT USE this tag for Microsoft Access, use [ms-access] instead
- Insert — Insert is an action to add information to a larger container that the information should reside within
- Syntax — Syntax refers to the actual language elements and symbols themselves
- Syntax error — A syntax error occurs when a program does not follow the syntactical rules of the programming language.
- Access — Microsoft Access, also known as Microsoft Office Access, is a database management system from Microsoft that commonly combines the relational Microsoft JetACE Database Engine with a graphical user interface and software-development tools
- Microsoft access — Microsoft Access, also known as Microsoft Office Access, is a database management system from Microsoft that commonly combines the relational Microsoft JetACE Database Engine with a graphical user interface and software-development tools
Symptoms of Code 3134 — Microsoft Access Error 3134
Runtime errors happen without warning. The error message can come up the screen anytime Microsoft Access is run. In fact, the error message or some other dialogue box can come up again and again if not addressed early on.
There may be instances of files deletion or new files appearing. Though this symptom is largely due to virus infection, it can be attributed as a symptom for runtime error, as virus infection is one of the causes for runtime error. User may also experience a sudden drop in internet connection speed, yet again, this is not always the case.
(For illustrative purposes only)
Causes of Microsoft Access Error 3134 — Code 3134
During software design, programmers code anticipating the occurrence of errors. However, there are no perfect designs, as errors can be expected even with the best program design. Glitches can happen during runtime if a certain error is not experienced and addressed during design and testing.
Runtime errors are generally caused by incompatible programs running at the same time. It may also occur because of memory problem, a bad graphics driver or virus infection. Whatever the case may be, the problem must be resolved immediately to avoid further problems. Here are ways to remedy the error.
Repair Methods
Runtime errors may be annoying and persistent, but it is not totally hopeless, repairs are available. Here are ways to do it.
If a repair method works for you, please click the upvote button to the left of the answer, this will let other users know which repair method is currently working the best.
Please note: Neither ErrorVault.com nor it’s writers claim responsibility for the results of the actions taken from employing any of the repair methods listed on this page — you complete these steps at your own risk.
Method 1 — Close Conflicting Programs
When you get a runtime error, keep in mind that it is happening due to programs that are conflicting with each other. The first thing you can do to resolve the problem is to stop these conflicting programs.
- Open Task Manager by clicking Ctrl-Alt-Del at the same time. This will let you see the list of programs currently running.
- Go to the Processes tab and stop the programs one by one by highlighting each program and clicking the End Process buttom.
- You will need to observe if the error message will reoccur each time you stop a process.
- Once you get to identify which program is causing the error, you may go ahead with the next troubleshooting step, reinstalling the application.
Method 2 — Update / Reinstall Conflicting Programs
Using Control Panel
- For Windows 7, click the Start Button, then click Control panel, then Uninstall a program
- For Windows 8, click the Start Button, then scroll down and click More Settings, then click Control panel > Uninstall a program.
- For Windows 10, just type Control Panel on the search box and click the result, then click Uninstall a program
- Once inside Programs and Features, click the problem program and click Update or Uninstall.
- If you chose to update, then you will just need to follow the prompt to complete the process, however if you chose to Uninstall, you will follow the prompt to uninstall and then re-download or use the application’s installation disk to reinstall the program.
Using Other Methods
- For Windows 7, you may find the list of all installed programs when you click Start and scroll your mouse over the list that appear on the tab. You may see on that list utility for uninstalling the program. You may go ahead and uninstall using utilities available in this tab.
- For Windows 10, you may click Start, then Settings, then choose Apps.
- Scroll down to see the list of Apps and features installed in your computer.
- Click the Program which is causing the runtime error, then you may choose to uninstall or click Advanced options to reset the application.
Method 3 — Update your Virus protection program or download and install the latest Windows Update
Virus infection causing runtime error on your computer must immediately be prevented, quarantined or deleted. Make sure you update your virus program and run a thorough scan of the computer or, run Windows update so you can get the latest virus definition and fix.
Method 4 — Re-install Runtime Libraries
You might be getting the error because of an update, like the MS Visual C++ package which might not be installed properly or completely. What you can do then is to uninstall the current package and install a fresh copy.
- Uninstall the package by going to Programs and Features, find and highlight the Microsoft Visual C++ Redistributable Package.
- Click Uninstall on top of the list, and when it is done, reboot your computer.
- Download the latest redistributable package from Microsoft then install it.
Method 5 — Run Disk Cleanup
You might also be experiencing runtime error because of a very low free space on your computer.
- You should consider backing up your files and freeing up space on your hard drive
- You can also clear your cache and reboot your computer
- You can also run Disk Cleanup, open your explorer window and right click your main directory (this is usually C: )
- Click Properties and then click Disk Cleanup
Method 6 — Reinstall Your Graphics Driver
If the error is related to a bad graphics driver, then you may do the following:
- Open your Device Manager, locate the graphics driver
- Right click the video card driver then click uninstall, then restart your computer
Method 7 — IE related Runtime Error
If the error you are getting is related to the Internet Explorer, you may do the following:
- Reset your browser.
- For Windows 7, you may click Start, go to Control Panel, then click Internet Options on the left side. Then you can click Advanced tab then click the Reset button.
- For Windows 8 and 10, you may click search and type Internet Options, then go to Advanced tab and click Reset.
- Disable script debugging and error notifications.
- On the same Internet Options window, you may go to Advanced tab and look for Disable script debugging
- Put a check mark on the radio button
- At the same time, uncheck the «Display a Notification about every Script Error» item and then click Apply and OK, then reboot your computer.
If these quick fixes do not work, you can always backup files and run repair reinstall on your computer. However, you can do that later when the solutions listed here did not do the job.
Other languages:
Wie beheben Fehler 3134 (Microsoft Access-Fehler 3134) — Syntaxfehler in der INSERT INTO-Anweisung.
Come fissare Errore 3134 (Errore di Microsoft Access 3134) — Errore di sintassi nell’istruzione INSERT INTO.
Hoe maak je Fout 3134 (Microsoft Access-fout 3134) — Syntaxisfout in INSERT INTO-instructie.
Comment réparer Erreur 3134 (Erreur Microsoft Access 3134) — Erreur de syntaxe dans l’instruction INSERT INTO.
어떻게 고치는 지 오류 3134 (마이크로소프트 액세스 오류 3134) — INSERT INTO 문에 구문 오류가 있습니다.
Como corrigir o Erro 3134 (Erro 3134 do Microsoft Access) — Erro de sintaxe na instrução INSERT INTO.
Hur man åtgärdar Fel 3134 (Microsoft Access-fel 3134) — Syntaxfel i INSERT INTO -sats.
Как исправить Ошибка 3134 (Ошибка Microsoft Access 3134) — Синтаксическая ошибка в инструкции INSERT INTO.
Jak naprawić Błąd 3134 (Błąd Microsoft Access 3134) — Błąd składni w instrukcji INSERT INTO.
Cómo arreglar Error 3134 (Error 3134 de Microsoft Access) — Error de sintaxis en la instrucción INSERT INTO.
About The Author: Phil Hart has been a Microsoft Community Contributor since 2010. With a current point score over 100,000, they’ve contributed more than 3000 answers in the Microsoft Support forums and have created almost 200 new help articles in the Technet Wiki.
Follow Us:
Last Updated:
05/09/22 07:13 : A iPhone user voted that repair method 1 worked for them.
This repair tool can fix common computer problems such as blue screens, crashes and freezes, missing DLL files, as well as repair malware/virus damage and more by replacing damaged and missing system files.
STEP 1:
Click Here to Download and install the Windows repair tool.
STEP 2:
Click on Start Scan and let it analyze your device.
STEP 3:
Click on Repair All to fix all of the issues it detected.
DOWNLOAD NOW
Compatibility
Requirements
1 Ghz CPU, 512 MB RAM, 40 GB HDD
This download offers unlimited scans of your Windows PC for free. Full system repairs start at $19.95.
Article ID: ACX06511EN
Applies To: Windows 10, Windows 8.1, Windows 7, Windows Vista, Windows XP, Windows 2000
Speed Up Tip #66
Use Keyboard Shortcuts:
Navigate through your computer quickly by learning how to use keyboard shortcuts. Windows programs such as Microsoft Excel and Outlook have a specific set of keyboard shortcuts for you to use efficiently. You can also create your own set of shortcuts for an even more personalized use.
Click Here for another way to speed up your Windows PC
-
runtime error 3134
Hey, I’m new here and new to access. I’m trying to set up a simple database for my company that I can keep track of the programs we write, and the customer we write them for, etc…
I’m having this recurring error with my code and I have no idea why it’s happening, I have looked at pretty much every resource to no avail.The error is
«Run-time error ‘3134’:
Syntax error in INSERT INTO statement.»Here is my code, any help would be very appreciated, thanks!
(I attempted to highlight the code that is giving me the error)
—————————————————————————————Private Sub cmdAdd_Click()
‘add data to table
CurrentDb.Execute «INSERT INTO PROGRAM(programid, programnum, robot, box, options, origrom, date, disk, customer) VALUES (» & Me.txtID & «,'» & Me.txtRobot & «‘,'» & _ Me.txtBox & «‘.'» & Me.txtOptions & «‘.'» & Me.txtRom & «‘.'» & Me.txtDate & _ «‘.'» & Me.txtDisk & «‘.'» & Me.txtCustomer & «‘)»
‘refresh data in list on form
frmProgramSub.Form.RequeryEnd Sub
Private Sub cmdClear_Click()
Me.txtNumber = «»
Me.txtRobot
Me.txtBox
Me.txtOptions
Me.txtRom
Me.txtDisk
Me.txtCustomer
Me.txtDateMe.txtID.SetFocus
End SubPrivate Sub cmdClose_Click()
DoCmd.CloseEnd Sub
Private Sub txtID_Click()
End Sub
—————————————————————————————
-
You’ve got some periods instead of commas, date fields would be surrounded by # rather than ‘. This should help debug it:
BaldyWeb-Immediate window
-
Your problem is the field «date» in the field list. «Date» should be considered a reserved word — this is one case where it causes problems in Access (SQL, actually).
There are two solutions — one is to rename the «Date» field in your table to (for example) Program_Date if it is practical to do so; the other option is to use [Date], in square brackets in the value list so Access knows it is a field name.
Forum Rules |
|
-
#1
Hello everyone,
I’m venturing into my first attempts at sql and am getting a «Run-time error ‘3134’: Syntax error in INSERT INTO statement. Here’s the code below. Any suggestions??
Private Sub cmdSaveLabRequest_Click()
Dim strCriteria As String
Dim strSQL As String
If Me.unbOrderedBy = «» Then
MsgBox (» Ordered By field cannot be blank»)
Else
If Me.cmbMinistry = «Select Ministry» Then
MsgBox (» Select Ministry»)
Else
DoCmd.SetWarnings False
DoCmd.RunSQL «INSERT INTO tblOSHWALabRequests (Candidate, ApplicantID, Req, StartDate, DOB, Position, PL-Dept, Ministry, DateLabsOrdered, OrderedBy, AllNewHireLabs, QuantiferonGold, RubeollaAntibody, RubellaAntibody, MumpsTiter, HepBSurfAntigen, UrineDrug, LeadLabTests, BloodLead, ZincProtoporphyrin, LeadCBCDiff, OncLabTests, OncCBCDiff, CMBP, SGPT, DCProviderLabTests, DCCBCDiff, MiscLabTests, VaricellaAntibody, UAHCG,) Values (cmbCandidate, unbApplicantID, unbReq, unbStartDate, unbDOB, unbPosition, unbPLDept, cmbMinistry, unbDateOrdered, unbOrderedBy, unbAllLabs, unbAllTests1, unbAllTests2, unbAllTests3, unbAllTests4, unbAllTests5, unbAllTests6, unbPBTests, unbPBTest1, unbPBTest2, unbPBTest3, OncTests, OncTest1, OncTest2, OncTest3, OncTest4, unbDCProvidersTests, unbDCProvidersTest1, unbMiscTests, unbMiscTest1, unbMiscTest2)»
End If
End If
Me.Refresh
DoCmd.SetWarnings True
End Sub
JANR
Registered User.
-
#2
Point 1
All SQL has to be on one string, for long SQL statements breake it up in pieces to be more readeble, if your code is as you posted it. Then add a linecontinue at the end of the individuelle lines.
Code:
....[FONT=Arial]OrderedBy, [COLOR=red]& [/COLOR][COLOR=red]_[/COLOR][/FONT]
A better way is to build it up gradually:
Code:
Dim strSQL As String
strSQL = ""
strSQL = strSQL & " INSERT INTO....."
strSQL = strSQL & " (candidate, [FONT=Arial]ApplicantID...."[/FONT]
[FONT=Arial].....[/FONT]
[FONT=Arial]....[/FONT]
DoCmd.RunSQL strSQL
Point 2:
In your values bit make sure to wrap textfields in « « , DateFields #SomeDate#
Point 3:
Why are you using what looks like unbound form, when binding it to a table/Query is so much easier.
Sidenote, your syntax error is probably this bit:
Code:
...[FONT=Arial]VaricellaAntibody, UAHCG[COLOR=red][B],[/B][/COLOR]) Values.... [/FONT]
Remove the extra comma, but I don’t think it will run as you expect, do a Debug.Print of the SQL before you execute is also a good idea.
Just my 5 cents
JR
Last edited: Dec 8, 2009
-
#3
Thanks for your guidance on this. Makes sense to break it into smaller pieces and I tried to add the «&_» followed by a new line — hope I got the syntax right. Again, thanks for your help as I dip my feet in the SQL water!
Do you see any obvious problems with what I’ve got below?
Is the «Do.cmd.RunSQL strSQL» right at the end?
Dim strCriteria As String
Dim strSQL As String
strSQL = «»
strSQL = strSQL & «INSERT INTO tblOSHWALabRequests»
strSQL = strSQL & «(Candidate, ApplicantID, Req, StartDate, DOB, Position, PL-Dept, & _ Ministry, DateLabsOrdered, OrderedBy, AllNewHireLabs, QuantiferonGold, RubeollaAntibody, & _
RubellaAntibody, MumpsTiter, HepBSurfAntigen, UrineDrug, LeadLabTests, BloodLead, & _
ZincProtoporphyrin, LeadCBCDiff, OncLabTests, OncCBCDiff, CMBP, SGPT, & _
DCProviderLabTests, DCCBCDiff, MiscLabTests, VaricellaAntibody, UAHCG)»
strSQL = strSQL & «Values»
strSQL = strSQL & «(cmbCandidate, unbApplicantID, unbReq, #unbStartDate#, #unbDOB#, & _
unbPosition, unbPLDept, cmbMinistry, #unbDateOrdered#, unbOrderedBy, unbAllLabs, & _
unbAllTests1, unbAllTests2, unbAllTests3, unbAllTests4, unbAllTests5, unbAllTests6, & _
unbPBTests, unbPBTest1, unbPBTest2, unbPBTest3, OncTests, OncTest1, OncTest2, & _
OncTest3, OncTest4, unbDCProvidersTests, unbDCProvidersTest1, unbMiscTests, & _
unbMiscTest1, unbMiscTest2)»
DoCmd.RunSQL strSQL
JANR
Registered User.
-
#4
Here is a better and cleaner SQL string:
Code:
Dim strSQL As String
strSQL = ""
strSQL = strSQL & " INSERT INTO tblOSHWALabRequests"
strSQL = strSQL & " (Candidate, ApplicantID, Req, StartDate, DOB, Position, PL-Dept, [COLOR=red][B][[/B][/COLOR]& _ Ministry[COLOR=red][B]][/B][/COLOR], DateLabsOrdered, OrderedBy, AllNewHireLabs, QuantiferonGold, RubeollaAntibody,"
StrSQL = strSQL & " RubellaAntibody, MumpsTiter, HepBSurfAntigen, UrineDrug, LeadLabTests, BloodLead, ZincProtoporphyrin, LeadCBCDiff, OncLabTests, OncCBCDiff, CMBP, SGPT,"
strSQL = strSQL & " DCProviderLabTests, DCCBCDiff, MiscLabTests, VaricellaAntibody, UAHCG)"
strSQL = strSQL & " Values"
strSQL = strSQL & " (cmbCandidate, unbApplicantID, unbReq, #unbStartDate#, #unbDOB#, unbPosition, unbPLDept, cmbMinistry, #unbDateOrdered#, unbOrderedBy, unbAllLabs,"
strSQL = strSQL & " unbAllTests1, unbAllTests2, unbAllTests3, unbAllTests4, unbAllTests5, unbAllTests6, unbPBTests, unbPBTest1, unbPBTest2, unbPBTest3, OncTests, OncTest1, OncTest2,"
strSQL = strSQL & " OncTest3, OncTest4, unbDCProvidersTests, unbDCProvidersTest1, unbMiscTests, unbMiscTest1, unbMiscTest2)"
Debug.Print strSQL
'Currentdb.Extecute strSQL, dbFailOnError ' if strSQL looks ok, then uncomment line.
Note the brackets [], a fieldname like &_Ministry in a table is asking for trouble!!!
Also are all your fields in the target table numbers exept a few dates? If some are text you must wrap them in quotes. I also would use Execute methode instead of Docmd.RunSql, then you don’t have to turn Warings on and off.
But you still haven’t given an answer on why you think this is the best way to accomplice you goal. I still think a bound form is the way to go.
JR
FYI Where are the values coming from? If they are fields in a form you have to refrence the properly, like Me!cmbCandidate and so on. If this is a Form Module.
Last edited: Dec 9, 2009
-
#5
Also note that
If Me.unbOrderedBy = «» Then
is not going to tell you if the field is blank. A blank field in Access, including fields that have had data and subsequently had the data deleted is Null. To check for Nulls
If Nz(Me.unbOrderedBy, «») = «» Then
-
#6
but you cant set the values out as you have — if they are variables they need to be formatted differently.
This is crazy — if you are new to access, use bound forms until you understand what is going on.
JANR
Registered User.
-
#7
but you cant set the values out as you have — if they are variables they need to be formatted differently.
This is crazy — if you are new to access, use bound forms until you understand what is going on.
Well spoken, large Insert statements should be avoided it to easy to get the order or syntax wrong. One wrong character and you be debugging for ever.
Just to give you some idee, in your value fields you must wrap every field correctly.
Code:
Every textfield must use this wrapper: '" & Me!textfield & "'
Numberfield must use this wapper: " & Me!NumberField & "
Datefields must be wrapped like this: #" & Me!DateField & "#
If you do not use US date format mm/dd/yyyy, then you have to Formate the datefields before you send it to the table.
JR
-
#8
I’m going to throw out a tip as it’s worked for me and I haven’t seen it recommended on the boards.
When I’m having a hard time with sql I just use Access to build my query the way I need it. I can test it (Except for code variables but those are easy to substitute in code — it also helps me figure out if my variables are what’s screwing things up)
If my access query works I just flip it over to sql view, copy & paste then fix the formatting to make the vba happy.
-
#9
JANR,
Thanks for simplifying the code. I see where I was going wrong, as I wasn’t sure how to wrap the line in quotations for subsequent StrSQL = strSQL & » lines.
The good news is. I’m no longer getting errors. The not-so-good news is that it is not updating my table. The field names for the table are correct in the string as are the forms field names. What am I missing?
JANR
Registered User.
-
#10
The good news is. I’m no longer getting errors. The not-so-good news is that it is not updating my table. The field names for the table are correct in the string as are the forms field names. What am I missing?
Hard to say without seeing your full code, could be as simpel as an uncomment RunCommand, like:
Code:
'Currentdb.Execute strSQL....
Any errors would also help, I’m not a psychic
JR
-
#11
What you lack in psychic abilities, you more than make up for in patience and good old-fashioned Access know-how!
No errors. The code you supplied worked brilliantly in getting rid of that! Here’s the entire code from the On Click Event Procedure:
Private Sub cmdSaveLabRequest_Click()
If Me.unbOrderedBy = «» Then
MsgBox (» Ordered By field cannot be blank»)
Else
If Me.cmbMinistry = «Select Ministry» Then
MsgBox (» Select Ministry»)
Else
DoCmd.SetWarnings False
Dim StrSQL As String
Dim strCriteria As String
StrSQL = «»
StrSQL = StrSQL & » INSERT INTO tblOSHWALabRequests»
StrSQL = StrSQL & » (Candidate, ApplicantID, Req, StartDate, DOB, Position, PL-Dept, [& _ Ministry], DateLabsOrdered, OrderedBy, AllNewHireLabs, QuantiferonGold, RubeollaAntibody,»
StrSQL = StrSQL & » RubellaAntibody, MumpsTiter, HepBSurfAntigen, UrineDrug, LeadLabTests, BloodLead, ZincProtoporphyrin, LeadCBCDiff, OncLabTests, OncCBCDiff, CMBP, SGPT,»
StrSQL = StrSQL & » DCProviderLabTests, DCCBCDiff, MiscLabTests, VaricellaAntibody, UAHCG)»
StrSQL = StrSQL & » Values»
StrSQL = StrSQL & » (cmbCandidate, unbApplicantID, unbReq, #unbStartDate#, #unbDOB#, unbPosition, unbPLDept, cmbMinistry, #unbDateOrdered#, unbOrderedBy, unbAllLabs,»
StrSQL = StrSQL & » unbAllTests1, unbAllTests2, unbAllTests3, unbAllTests4, unbAllTests5, unbAllTests6, unbPBTests, unbPBTest1, unbPBTest2, unbPBTest3, OncTests, OncTest1, OncTest2,»
StrSQL = StrSQL & » OncTest3, OncTest4, unbDCProvidersTests, unbDCProvidersTest1, unbMiscTests, unbMiscTest1, unbMiscTest2)»
Debug.Print StrSQL
‘Currentdb.Extecute strSQL, dbFailOnError ‘ if strSQL looks ok, then uncomment line.
End If
End If
Me.Refresh
DoCmd.SetWarnings True
End Sub
JANR
Registered User.
-
#12
I am a psychic after all. remove the ‘ before the currentdb.Execute line.
In your code this line should be green, meaning Access skips this line and treats it as a commentline.
Commentlines are useful to explane different things about your code, so when you revist it later it’s easier to understand what the code is supose to do. Make a habbit of this and life is easier.
JR
-
#13
Comment lines make a lot of sense — cool feature. That said, I got rid of the tick mark so the line reads:
Currentdb.Extecute strSQL, dbFailOnError ‘ if strSQL looks ok, then uncomment line.
Back to getting Run-tim error 3134. So, I tried just
Currentdb.Extecute strSQL, dbFailOnError
Still getting error. Debuging takes me to the Currentdb…. line and highlights it in yellow. When I do the right-click and run to cursor I still get the same «Run-time error»
-
#14
looks like on the last line you have a ‘Currentdb.Extecute instead you should have a CurrentDB.execute.
Not sure if this will help.
JANR
Registered User.
-
#15
That’s because you haven’t read what you’ve been told be me and others!
I expected that this code woulden’t run because you haven’t wrapped your value field’s like I told.
Every textfield must use this wrapper: ‘» & Me!textfield & «‘
Numberfield must use this wapper: » & Me!NumberField & «
Datefields must be wrapped like this: #» & Me!DateField & «#
Also your logic int the if’s are not clear, see Missinglinq’s post.
Also note that
If Me.unbOrderedBy = «» Then
is not going to tell you if the field is blank. A blank field in Access, including fields that have had data and subsequently had the data deleted is Null. To check for Nulls
If Nz(Me.unbOrderedBy, «») = «» Then
Also by using Execute metode you don’t need to set the warnings on/off, and you have unused variables like. If you don’t use it, don’t declare it is the rule.
Code:
Dim strCriteria As String
Here is a start for you of a cleaner code. I have started on some of your value field’s on pure guesswork Numbers and dates, but if some are text you have to change it to the right wrapper.
Code:
Option Compare Database
Option Explicit
Private Sub cmdSaveLabRequest_Click()
If Nz(Me.unbOrderedBy, "") = "" Then
MsgBox " Ordered By field cannot be blank"
Exit Sub ' no point to go so exit sub.
Else
If Me.cmbMinistry = "Select Ministry" Then ' dosen't make sence to me??
MsgBox " Select Ministry"
Else
Dim StrSQL As String
StrSQL = ""
StrSQL = StrSQL & " INSERT INTO tblOSHWALabRequests"
StrSQL = StrSQL & " (Candidate, ApplicantID, Req, StartDate, DOB, Position, PL-Dept, [& _ Ministry], DateLabsOrdered, OrderedBy, AllNewHireLabs, QuantiferonGold, RubeollaAntibody,"
StrSQL = StrSQL & " RubellaAntibody, MumpsTiter, HepBSurfAntigen, UrineDrug, LeadLabTests, BloodLead, ZincProtoporphyrin, LeadCBCDiff, OncLabTests, OncCBCDiff, CMBP, SGPT,"
StrSQL = StrSQL & " DCProviderLabTests, DCCBCDiff, MiscLabTests, VaricellaAntibody, UAHCG)"
StrSQL = StrSQL & " Values"
StrSQL = StrSQL & " (" & cmbCandidate & ", " & unbApplicantID & ", " & unbReq & ", #" & unbStartDate & "#, #" & unbDOB & "#, unbPosition, unbPLDept, cmbMinistry, #" & unbDateOrdered & "#, unbOrderedBy, unbAllLabs,"
StrSQL = StrSQL & " unbAllTests1, unbAllTests2, unbAllTests3, unbAllTests4, unbAllTests5, unbAllTests6, unbPBTests, unbPBTest1, unbPBTest2, unbPBTest3, OncTests, OncTest1, OncTest2,"
StrSQL = StrSQL & " OncTest3, OncTest4, unbDCProvidersTests, unbDCProvidersTest1, unbMiscTests, unbMiscTest1, unbMiscTest2)"
'Debug.Print StrSQL 'uncomment during development
CurrentDB.Execute StrSQL, dbFailOnError ' if strSQL looks ok, then uncomment line.
End If
End If
Me.Refresh
End Sub
Also indenting all your code work, helps to understand it better.
JR
-
#16
TallMan,
JANR caught that one for me and I removed the tick mark. Back to getting the error.
-
#17
Thank for your guidance JANR and TallMan. A few tweaks and I got it…
Dim StrSQL As String
Dim strCriteria As String
StrSQL = «»
StrSQL = StrSQL & » INSERT INTO tblOSHWALabRequests»
StrSQL = StrSQL & » (Candidate, ApplicantID, Req, StartDate, DOB, Position, [PL-Dept], Ministry, DateLabsOrdered, OrderedBy, AllNewHireLabs, «
StrSQL = StrSQL & » QuantiferonGold, RubeollaAntibody, RubellaAntibody, MumpsTiter, HepBSurfAntigen, UrineDrug, LeadLabTests, BloodLead, ZincProtoporphyrin, LeadCBCDiff, OncLabTests, OncCBCDiff,»
StrSQL = StrSQL & » CMBP, SGPT, Urinalysis, DCProviderLabTests, DCCBCDiff, MiscLabTests, VaricellaAntibody, UAHCG)»
StrSQL = StrSQL & » Values»
StrSQL = StrSQL & » (‘» & cmbCandidate & «‘,'» & unbApplicantID & «‘, » & unbReq & «, #» & unbStartDate & «#,#» & unbDOB & «#,'» & unbPosition & «‘,'» & unbPLDept & «‘,'» & cmbMinistry & «‘,#» & unbDateOrdered & «#,'» & unbOrderedBy & «‘,» & unbAllLabs & «,»
StrSQL = StrSQL & » » & unbAllTests1 & «, » & unbAllTests2 & «, » & unbAllTests3 & «, » & unbAllTests4 & «, » & unbAllTests5 & «, » & unbAllTests6 & «, » & unbPBTests & «, » & unbPBTest1 & «, » & unbPBTest2 & «, » & unbPBTest3 & «, » & OncTests & «, » & OncTest1 & «, » & OncTest2 & «,»
StrSQL = StrSQL & » » & OncTest3 & «, » & OncTest4 & «, » & unbDCProvidersTests & «, » & unbDCProvidersTest1 & «, » & unbMiscTests & «, » & unbMiscTest1 & «, » & unbMiscTest2 & «)»
DoCmd.RunSQL StrSQL
-
#18
Did I count the Fields and Controls right.
I got 30 Fields and 31 Controls.
Suggest you try just one insert. When that works add another and so on.
Last edited: Dec 12, 2009
-
#19
I am not saying that this is correct, but this is how I would format the String.
Code:
Private Sub cmdSaveLabRequest_Click()
Dim strSQL As String
If Len(Me.unbOrderedBy) Then
If Me.cmbMinistry = "Select Ministry" Then
MsgBox " Select Ministry"
Else
strSQL = " INSERT INTO tblOSHWALabRequests " & _
" (Candidate, ApplicantID, Req, StartDate, DOB, Position, PL-Dept, Ministry, DateLabsOrdered, OrderedBy, " & _
" AllNewHireLabs, QuantiferonGold, RubeollaAntibody, RubellaAntibody, MumpsTiter, HepBSurfAntigen, " & _
" UrineDrug, LeadLabTests, BloodLead, ZincProtoporphyrin, LeadCBCDiff, OncLabTests, OncCBCDiff, CMBP, SGPT, " & _
" DCProviderLabTests, DCCBCDiff, MiscLabTests, VaricellaAntibody, UAHCG) " & _
" Values " & _
" (cmbCandidate, unbApplicantID, unbReq, #unbStartDate#, #unbDOB#, unbPosition, unbPLDept, cmbMinistry, " & _
" #unbDateOrdered#, unbOrderedBy, unbAllLabs, unbAllTests1, unbAllTests2, unbAllTests3, unbAllTests4, " & _
" unbAllTests5, unbAllTests6, unbPBTests, unbPBTest1, unbPBTest2, unbPBTest3, OncTests, OncTest1, OncTest2, " & _
" OncTest3, OncTest4, unbDCProvidersTests, unbDCProvidersTest1, unbMiscTests, unbMiscTest1, unbMiscTest2)"
CurrentDb.Execute strSQL, dbFailOnError
Else
MsgBox " Ordered By field cannot be blank"
End If
End If
Me.Refresh
End Sub
Last edited: Dec 13, 2009
-
#20
I have to agree with Dave here! A big part of the reason to use Access for database development is the speed with which it can be created, using bound forms. Several developers I know, experienced in Visual Basic database development and Access development, estimate that development using unbound forms takes twice as long as it does when using Access and bound forms.
If you insist on using unbound forms, you’d be far better off using a Visual Basic or C++ front end with a SQL Server or Oracle back end, because
- You can create an EXE file which gives total protection to your code/design
- You can distribute the db to PCs without a copy of Access being on board
- Your data security if far, far better than anything you can do in Access