473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Single lstbox with 3 text boxes

Hi all,

Still trying to get a grip on lstboxes. This is my latest syntax error.

Form is setup this way.

one unbound multi-select lstbox (lsttechnique) populates correctly set to extended column count 1 bound column 1.

3 unbound txtboxes as follows:

txtbrfid dtatype number
txtfreq datatype number
txttotdur datatype number

brfid is pulled from form that opened this form and comes in correctly
freq and totdur are typed in by end user.
lsttechnique is various techniques used

cmdaddtech has the follwing code:

Private Sub cmdaddtech_Click()
Dim db As DAO.Database
Dim varItem As Variant


Set db = CurrentDb


With Me.lsttechnique
For Each varItem In .ItemsSelected


db.Execute _
"INSERT INTO tblNSCIPRLessRestrictive " & _
"(Brfid, Technique, Freq, totdur) " & _
"VALUES (" & _
.ItemData(varItem) & ", " & _
Chr(34) & Me.txtFreq & Chr(34) & ", " & _
Chr(34) & Me.txtTotdur & Chr(34) & ", " & _
Chr(34) & Me.txtBRFID & Chr(34) & ", " & _
dbFailOnError


Next varItem
End With

myReply = MsgBox("Are you sure you want to add this/these techniques?", vbYesNo)
If myReply = vbYes Then
DoCmd.Requery
End If
End Sub

When I click it I get a runtime error 3075 with missing operator in query expression with the selection I choose in the lsttechnique in single quotes.

exact error is Syntax error (missing operator) in query expression 'One are release'.

Thanks in advance
Apr 29 '10 #1
2 1166
robjens
37
Your SQL like this won't work. As the the program says, there is something in your query that is wrong. I always check my queries inside the querybuilder sql view to make sure it returns the right values and make sure the syntaxis is correct.

First comment, you are using double quotes in the VBA SQL string, that won't work like this. You need to use single quotes for text values, none for numbers or boolean and sharp for dates. You also don't need Chr(34) for this.

For readability I would always use a short named variable but not required tho. Also I advise to take a look at your naming conventions. The table name is a bit off. Last, no need to use With here is there?

This query should work:

db.Execute _
("INSERT INTO MyTable (fldString1, fldInt2, fldBool3) VALUES " & _
('" & strValue1 & "', " & intValue2 & ", " & IsChecked3 & ";")
dbFailOnError
May 1 '10 #2
Thanks for the reply, but I couldn't get that to work. I copied your example in, changed it to my values and got compile error. Doesn't like this.

'" & strValue1 & "'

I will play with it some more. Just learning so forgive me if I am missing the obvious.
May 3 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: |-|erc | last post by:
these 3 lines will put the following into the URL bar! but with 2 input boxes it doesn't. <form name=test> <INPUT name='selqty2'> </form> file:///C:/WINDOWS/DESKTOP/tttt2.html?selqty2=55555
2
by: chrisse_2 | last post by:
I currently have a form with a two text boxes and two list boxes. Now, i want the user to be able to type information into two of the text boxes and select an item from one of the list boxes; with...
1
by: iMedia User | last post by:
I have a site where I want to use the Web form validators in two separate forms on a single page. One form allows existing users to log in while the second one allows new users to register. The...
10
by: Siv | last post by:
Hi, I am struggling with VB.NET's lack of indexing on controls. I have a form with 23 text boxes and I want to be able to drag some items in a list to any one of those text boxes. In VB6 I...
2
by: Lal | last post by:
dear all On my project all forms have 10-25 text boxes, i want to clear these text boxes. insted of typing .clear on every text boxes any single command for a particular form i am new in .net...
11
by: Edson Peacock | last post by:
I have a report with sub reports, one of the subreports have 12 text boxes that are 2" high and I want them all to grow if one goes to 3" high. If anyone has any suggestions they are very much...
4
by: Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post by:
I have created a report. This report needs to display records between two dates entered by the user. I put two text boxes on the report so I can enter the start and end date - I set them to use an...
3
by: Major Doug | last post by:
Hello: situation--I have a research database. Each record in the database consists of 10 fields. I used access97 to rack/stack my database; very easy in the beginning. I created a form with a...
1
by: Josephbupe | last post by:
Please, i don't know about programming i want to learn. I am creating a motor vehicle database and i need three text boxes on a single form for carrying out queries. The text boxes are: (VIN) (Begin...
4
by: Dan2kx | last post by:
Good eve peeps, got a quicky for ya (hopefully) i have two multiselect listboxes on a form and i would like a query to show all the selected values from both boxes, i tried to sting the data...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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
0
BarryA
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...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.