Textbox value not inserting

c19h28O2

Registered User.
Local time
Today, 00:54
Joined
Jan 23, 2007
Messages
12
Hi,

Can anyone tell me what i'm doing wrong with this insert statement?

Code:
INSERT INTO TBL_PROCESS_NAME
VALUES( ' & [Forms]![frmIntroduction]![txtProcess_Name] & ' )

the form is loaded when the query is run, i've tried taking out the & and the ' but to no avail, all i get in the table is [Forms]![frmIntroduction]![txtProcess_Name]

Thanks

Michael
 
You are not defining in the query what field you want to insert the data into.
 
Hi,

The table has only one field? when i run the query the table shows a value of [forms]![frmIntroduction..... so it looks like its not replacing the value with whats in the text box, but it is inserting data..
 
c19h28O2 said:
The table has only one field?
I don't know. It's your table. Or is your question mark just out of place?

when i run the query the table shows a value of [forms]![frmIntroduction..... so it looks like its not replacing the value with whats in the text box, but it is inserting data..

Right. Where is the query? Is it within a bit of VBA code? Is it an actual SQL query definition?
 
Ahh i see what you mean, that was meant to mean, "its one field so do i still need to declare what field to input" but i suppose your not a mind reader so apologies for that!

Its in an append query.

Thanks

Michael
 
Okay. What you are doing wrong is using the apostrophe as a delimiter. The effect that this has is that it turns your reference to the form control into a string literal, so it doesn't see the value within the box, but the text (as text) between the string delimiter.

What you are looking for is something like this:

Code:
INSERT INTO TBL_PROCESS_NAME ( [b]YourFieldName[/b] )
VALUES ( [Forms]![frmIntroduction]![txtProcess_Name] );
 
Thanks, that would make sense re the apostrophe.

I've amended the code but the inserted is blank. I've double checked the form name and the textbox name, also the field is unbound (not sure if that makes a difference) also the form is running when I input the value into it. Any ideas what else i could be doing wrong?

Thanks
 
Hi SJ McAbney,

This solved the problem,

INSERT INTO TBL_PROCESS_NAME ( PROCESS_NAME )
SELECT Forms!frmIntroduction!txtProcess_Name.Text AS Expr1;

I clicked on the Design View and then back to the sql view and it started working.

Thanks for your help
 

Users who are viewing this thread

Back
Top Bottom