I have a query that worked months ago, but after adding additional fields to the target table, the query no longer runs. It took values from text controls on a form. It no longer finds them, so it displays parameter messages instead.
I shortened it up just to test it and even with only one field it doesn't work.
The Patient ID, aka the Me.txt62 field is never null. I have tried setting the focus, but that didn't help.
Short form: - DoCmd.RunSQL "INSERT INTO PatientReferralEditsTable (PatientID) VALUES (Me.txt62)"
Originally, it was in the form: - DoCmd.RunSQL "INSERT INTO PatientReferralEditsTable (PatientID, PhysicianID, PhysicianOfficeID, InsuranceCarrierID, InsuranceCarrierContractID, " & _
-
"ICD9Code1ID, ICD9Code2ID, ICD9Code3ID, ServiceDiscipline1ID, ServiceDiscipline2ID, ServiceDiscipline3ID, " & _
-
"PhysicianPhysicianOfficeID, PatientInsuranceCarrierID, PatientReferralID, PatientPhysicianID, PatientPhysicianOfficeID, " & _
-
"PRICD9Code1ID, PRICD9Code2ID, PRICD9Code3ID, " & _
-
"PRServiceDiscipline1ID,PRServiceDiscipline2ID,PRServiceDiscipline3ID) " & _
-
-
" VALUES (Me.txt62, Me.txt63, Me.Txt64, Me.Txt65, Me.Txt66), " & _
-
"Me.Txt67, Me.Txt68, Me.Txt69, Me.Txt106, Me.Txt107, Me.Txt108," & _
-
"Me.Txt70, Me.Txt71, Me.Txt72, Me.Txt73, Me.Txt74, " & _
-
"Me.Txt75, Me.Txt76, Me.Txt77, Me.Txt136, Me.Txt137, Me.Txt138)"
David
This - DoCmd.RunSQL "INSERT INTO PatientReferralEditsTable (PatientID) VALUES (Me.txt62)"
Needs to be this - DoCmd.RunSQL "INSERT INTO PatientReferralEditsTable (PatientID) VALUES ('" & Me.txt62 & "')"
Assuming PatientID is a string, if it's a number then leave out the single quotes.
The SQL engine has no idea what Me.txt62 is referring to. You need to append the value, not the reference.
The original form should not have worked either. If that's how the code truly looked, there's no way it should have run without error.
2 1070
This - DoCmd.RunSQL "INSERT INTO PatientReferralEditsTable (PatientID) VALUES (Me.txt62)"
Needs to be this - DoCmd.RunSQL "INSERT INTO PatientReferralEditsTable (PatientID) VALUES ('" & Me.txt62 & "')"
Assuming PatientID is a string, if it's a number then leave out the single quotes.
The SQL engine has no idea what Me.txt62 is referring to. You need to append the value, not the reference.
The original form should not have worked either. If that's how the code truly looked, there's no way it should have run without error.
NeoPa 32,556
Expert Mod 16PB How to Debug SQL String will give you the tools and experience to understand what Rabbit's saying more easily.
He's perfectly correct, of course. There must be some misunderstanding as the code you've posted could not possibly work as shown.
When you've played with it a bit you'll appreciate why that is and why working with SQL in VBA can be confusing for so many.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: johnnyboy10017 |
last post by:
I am having a hell of a time with what I think is a very simple query:
It won't actually insert a new record into the specified table, but
returns no error, in fact it returns "1" (or true) that...
|
by: avinash |
last post by:
hello myself avinash
i am developing on application having vb 6 as front end and sql server 7
as back end.
when i use insert query to insert data in table then the date value of
that query is...
|
by: Carl |
last post by:
Hi,
I hope someone can share some of their professional advice and help me out
with my embarissing problem concerning an Access INSERT query. I have never
attempted to create a table with...
|
by: GD |
last post by:
Hi,
There are serveral validation controls in our intranet application. The
controls work fine on all of our local machines that have Windows XP
professional operating systems on them. After...
|
by: Annie |
last post by:
hello guys,
I have little experience working with C# and MS Access ...
I am having an insert query with one datetime field and a boolean and couple
of text and number fields as below:
...
|
by: spam |
last post by:
If I run the following query in Access 2002 then I get the expected
result:
SELECT *
FROM CSVImport
UNION SELECT *
FROM AssetTemp;
I get the contents of both tables with no duplicates. If I...
|
by: clickon |
last post by:
I want to use an INSERT Query as the value for the UpdateCommand property of
an SQL datasource, anyone know if this will actually work ?
The reason i want to do it is bacause i am taking values...
|
by: rubinamunir |
last post by:
Hi.
i need help in insert query . i am working in php and oracle there i need insert datetime.i don't know the format please tell me how can i insert date with time in oracle and wht must...
|
by: deedi |
last post by:
Hi everyone,
I have a query which will insert records into a table . But when i execute the query in asp, it's not getting inserted in the table (the same query works well in SQL...
|
by: Luqman |
last post by:
I have created a Insert Query in Sql Data Source using Oracle Database, with
the parameters, and its connected with DetailView Control.
When I try to Insert through DetailView Control, Illegal...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |