Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO TBL IS NOT WRITING TO TABLE

Status
Not open for further replies.

bailey11

Technical User
Jan 18, 2005
103
US
TABLE TO WRITE TO: TblTimeEquip

FIELDS IN TABLE:
EquipNo (Text field)
JobNumberEq (Text Field)
ActivityCodeEQ (Text Field)
EQDate (Date Field)
PhaseEQ (Text Field)
EQHours (Number Field)
EqComments (Text Feild)
TruckYNEQ (Text Field)



If Me.Units >= 0.01 Then

SQL = "INSERT INTO tbltimeequip (EquipNo, JobNumberEQ, ActivityCodeEQ, EQDate, PhaseEQ, " & _
"EqHours, EqComments, TruckYNEQ) " & _
"VALUES ('" & Me.EquipIDTE & "','" & Me.ProjectNoCB & "','" & Me.CostCodeCB & _
"',#" & Me.WorkDate & "#,'" & Me.PhaseCB & Me.Units & _
",'" & Me.Description & "','" & Me.TMCO & "','" & Me.TkYN & "')"

DB.Execute SQL

Can anyone see why it wouldn't be writing to the table. It walks through the code okay, but no results in the table show up.

THanks, Bailey 11
 
You seem to have an error in the SQL:

[tt]SQL = "INSERT INTO tbltimeequip (EquipNo, JobNumberEQ, ActivityCodeEQ, EQDate, PhaseEQ, " & _
"EqHours, EqComments, TruckYNEQ) " & _
"VALUES ('" & Me.EquipIDTE & "','" & Me.ProjectNoCB & "','" & Me.CostCodeCB & _
"',#" & Me.WorkDate & "#,'" & Me.PhaseCB & Me.Units & _
"[COLOR=red yellow]'[/color],'" & Me.Description & "','" & Me.TMCO & "','" & Me.TkYN & "')"[/tt]

You may wish to use dbFailOnError:

[tt]Db.Execute SQL, dbFailOnError[/tt]

 
I took that out, but it still doesn't write to the table.
 
Took that out"? Do you mean added in a single quote or took out the error? Are you sure of all your field types? For example, is EquipNo a text field?
 
The added single quote. Yes, EquipNo is a text field. It seems to be the one causing me the most trouble.

I designed a similar form, but the leading field was a numeric field and everything went smoothly, but this I can't seem to get correct.
 
Try writing the SQL to the Immediate Window, to truobleshoot.

SQL = "INSERT INTO..."

Debug.Print SQL

'DB.Execute...


is it always failing or, only on some Inserts?
If some, then could be the data being inserted?

maybe Try CStr(Me.EquipIDTE) or

Replace(Me.Description,"'","''")
 
Hi...

If what you submitted is all the code you have in your command button....

Could it be that your users are not filling all the textboxes?

A blank box will be a null in your query and will fail to write to the table.

Have you thought of any checking to see if all boxes have something in them before running your query?


 
I don't think that the VALUES list match the fields list.
If Me.Description is really tbltimeequip.EQHours then it shouldn't be surronded by single quotes.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I have the form forcing them to enter all fields.

And no, Description is not EQHours, I have Me.Units as EqHours. (at the end of the 2nd line of values)
Do I not have that line formatted correctly?

Thanks, Bailey11
 
Do I not have that line formatted correctly?
From your original post:[tt]
EquipNo 'Me.EquipIDTE'
JobNumberEQ 'Me.ProjectNoCB'
ActivityCodeEQ 'Me.CostCodeCB'
EQDate #Me.WorkDate#
PhaseEQ 'Me.PhaseCB & Me.Units[!]'[/!]
EqHours 'Me.Description'
EqComments 'Me.TMCO'
TruckYNEQ 'Me.TkYN'[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You are GOD SENT!!!!!!!

I have been self teaching this stuff and I can't tell you how frustrating it has been and how much I appreciate you guys.

THANK YOU!!! THANK YOU!!!!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top