If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
What is wrong with this SQL string?
Hi guys,
I have a SQL string here that is intended to add the contents of a textbox into an unrelated table at the click of a button(the table is the rowsource for the textbox). DoCmd.RunSQL "INSERT INTO tblLetdownplaces([Place]) VALUES( " & Place.Value & ");" When I run this, it brings up a little dialog box asking me for the value of whatever text I have entered into the textbox.......eg. if I type in ABCD, it will ask for a value for ABCD. If I enter a value into the text box, it accepts it and places in the table. What am I doing wrong? Thanks guys. Kenny |
#2
|
|||
|
|||
What is wrong with this SQL string?
Hi Kenny,
Try Me.Place.Value instead of Place.Value. But IMHO it's usually a good idea to make sure that controls on forms don't have the same names as the fields they are bound to. So I'd call the textbox txtPlace instead, hence Me.txtPlace.Value This assumes that the code is in the same form as the control. For a control on a different form you can use Forms("frmName").Controls("txtPlace").Value or Forms!frmName!txtPlace On Sun, 1 Aug 2004 08:13:41 +0200, Kenny wrote: Hi guys, I have a SQL string here that is intended to add the contents of a textbox into an unrelated table at the click of a button(the table is the rowsource for the textbox). DoCmd.RunSQL "INSERT INTO tblLetdownplaces([Place]) VALUES( " & Place.Value & ");" When I run this, it brings up a little dialog box asking me for the value of whatever text I have entered into the textbox.......eg. if I type in ABCD, it will ask for a value for ABCD. If I enter a value into the text box, it accepts it and places in the table. What am I doing wrong? Thanks guys. Kenny -- John Nurick [Microsoft Access MVP] Please respond in the newgroup and not by email. |
#3
|
|||
|
|||
What is wrong with this SQL string?
Assuming that you're trying to load Text values and not Numeric ones, you
need quotes around your values. Try DoCmd.RunSQL "INSERT INTO tblLetdownplaces([Place]) VALUES( " & Chr$(34) & Place.Value & Chr$(34) & ");" Chr$(34) is the " character. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) Kenny wrote in message ... Hi guys, I have a SQL string here that is intended to add the contents of a textbox into an unrelated table at the click of a button(the table is the rowsource for the textbox). DoCmd.RunSQL "INSERT INTO tblLetdownplaces([Place]) VALUES( " & Place.Value & ");" When I run this, it brings up a little dialog box asking me for the value of whatever text I have entered into the textbox.......eg. if I type in ABCD, it will ask for a value for ABCD. If I enter a value into the text box, it accepts it and places in the table. What am I doing wrong? Thanks guys. Kenny |
#4
|
|||
|
|||
What is wrong with this SQL string?
Hi John,
Thanks for the reply.......unfortunately it did not work. The code is in the same form as the code. Just to be more specific about the error.......it comes up asking me to enter a parameter value. Ok.....any other ideas? Thanks Kenny "John Nurick" wrote in message ... Hi Kenny, Try Me.Place.Value instead of Place.Value. But IMHO it's usually a good idea to make sure that controls on forms don't have the same names as the fields they are bound to. So I'd call the textbox txtPlace instead, hence Me.txtPlace.Value This assumes that the code is in the same form as the control. For a control on a different form you can use Forms("frmName").Controls("txtPlace").Value or Forms!frmName!txtPlace On Sun, 1 Aug 2004 08:13:41 +0200, Kenny wrote: Hi guys, I have a SQL string here that is intended to add the contents of a textbox into an unrelated table at the click of a button(the table is the rowsource for the textbox). DoCmd.RunSQL "INSERT INTO tblLetdownplaces([Place]) VALUES( " & Place.Value & ");" When I run this, it brings up a little dialog box asking me for the value of whatever text I have entered into the textbox.......eg. if I type in ABCD, it will ask for a value for ABCD. If I enter a value into the text box, it accepts it and places in the table. What am I doing wrong? Thanks guys. Kenny -- John Nurick [Microsoft Access MVP] Please respond in the newgroup and not by email. |
#5
|
|||
|
|||
What is wrong with this SQL string?
Ok thanks Doug......that did it.
Kenny "Douglas J. Steele" wrote in message ... Assuming that you're trying to load Text values and not Numeric ones, you need quotes around your values. Try DoCmd.RunSQL "INSERT INTO tblLetdownplaces([Place]) VALUES( " & Chr$(34) & Place.Value & Chr$(34) & ");" Chr$(34) is the " character. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) Kenny wrote in message ... Hi guys, I have a SQL string here that is intended to add the contents of a textbox into an unrelated table at the click of a button(the table is the rowsource for the textbox). DoCmd.RunSQL "INSERT INTO tblLetdownplaces([Place]) VALUES( " & Place.Value & ");" When I run this, it brings up a little dialog box asking me for the value of whatever text I have entered into the textbox.......eg. if I type in ABCD, it will ask for a value for ABCD. If I enter a value into the text box, it accepts it and places in the table. What am I doing wrong? Thanks guys. Kenny |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Function isn't available in expressions in query expression | Reiner Harmgardt | General Discussion | 4 | July 21st, 2004 09:30 AM |
SQL string problem | Gary D. | Running & Setting Up Queries | 6 | June 7th, 2004 04:02 PM |
SQL string problem | Gary D. | Using Forms | 0 | June 1st, 2004 08:45 PM |
Question re MailMerge and VB.NET | thecoiman | Mailmerge | 5 | May 17th, 2004 04:13 PM |