473,503 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with grabbing data

Hothmire
5 New Member
Good afternoon all,

I am having some problems transferring data from my MS Form to an MS report. I am writing Code for a button Command to grab the information in the text boxs or combo boxes of a form and put the data into its respective place in the form. I use the following code to do so:

Expand|Select|Wrap|Line Numbers
  1. [Private Sub cmdProduceReport_Click()
  2.  
  3. MsgBox "Producing Initial Issue Report"
  4.  
  5. Dim strquery As String
  6.  
  7. strquery = "INSERT INTO [rptInitialIssue] " & _
  8.             "( [txtEmailSubject])" & _
  9.             "VALUES(" & _
  10.             "" & Me.EmailSubject_Date & "," & _
  11.             ")"
  12.  
  13. DoCmd.RunSQL strquery
  14.  
  15. MsgBox "Report has been Produced. Opening Report for export."
  16.  
  17. End Sub]
When I attempt this I receive the following error code.

Runtime-error '3705'

Syntax error (missing operator) in query expression. Can someone help me with this. Thank you
Dec 5 '12 #1
3 1713
zmbd
5,501 Recognized Expert Moderator Expert
Fairly simple insert query:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tbl_System 
  2.    ( system_pk, system_fk_location, 
  3.       system_fk_family, system_fk_station,
  4.        system_description )
  5. SELECT tbl_System_BCKUP.system_pk,
  6.    tbl_System_BCKUP.system_fk_location, 
  7.    tbl_System_BCKUP.system_fk_family, 
  8.    tbl_System_BCKUP.system_fk_station, 
  9.    tbl_System_BCKUP.system_description
  10. FROM tbl_System_BCKUP
  11. WHERE (((tbl_System_BCKUP.system_pk)>1));
  12.  
Take a look at how your SQL is resolving:
Insert STOP at Line 12,
<CTRL-G>
?strquery

Post this back.
Dec 5 '12 #2
Rabbit
12,516 Recognized Expert Moderator MVP
You need to put quotes around the value you're trying to insert. Also you have an extraneous comma towards the end.
Dec 5 '12 #3
NeoPa
32,557 Recognized Expert Moderator MVP
Please check out Before Posting (VBA or SQL) Code. If you have a SQL issue then we need to see your SQL rather than the code that creates the string that is sent to the SQL engine (Jet).

The code that does formulate your SQL has various literal strings concatenated together. That is pointless and confusing (more for you than us I suggest), so I'd tidy that up first if I were you. It also seems you are using a date field to insert into the SQL as a literal, yet the name of the field you are adding implies it is normal text ([txtEmailSubject]), and the format of the SQL is such that neither quotes (' - for string literals) nor hashes (# - for date literals) has been used.

As Rabbit says, you also append an extraneous comma after the value which will cause grief, probably because you got confused building up a string from a lot of smaller ones.
Dec 6 '12 #4

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

Similar topics

5
2573
by: Joe | last post by:
I need to connect to 10 web sites to grab content from them. I would like to connect to each site simultaneously so that I can obtain the data as fast as possible. I am familar doing this with...
0
1347
by: Ivan's Desk | last post by:
i need to grab data from the screen after the software has performed claculation and diplayed result on a form. there is no source code so i have to build VB to run particular software and then to...
2
1746
by: nic | last post by:
Hi I am currently having problems getting two forms to behave the way I want. I have two tables Student and Application, and their respective forms. (Tables)Student has StudentID (PK) & an...
1
1878
by: Aliza Klein | last post by:
Hi. A client of mine has a website with a standard "Contact Us" form page with name, address etc. The information is currently sent via email to the client and is then data entered into their...
0
1284
by: Jesper Stocholm | last post by:
I am using the example as the basis for an application I am currently writing. The setup consists of two applications (client and server) that talk to each other thru TCP. I have no problems...
3
3656
by: Lonewolf | last post by:
Hi all, I'm having difficulties passing data back to managed class from my native class when the data is generated from within a native thread in the native class itself. I will give the following...
4
2052
by: sgjwm | last post by:
I'm trying to set up a program to automatically grab a few data files from a data provider on a daily basis. There are however, several obstacles to this: 1) The site requires a login / password,...
0
880
by: baties | last post by:
i have designed a form to collate data and stored in a table in the sqlserver database. However, I am experiencing problems with the gathered data. Every piece of information transferred to the data...
2
3548
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
1
7228
by: Dave | last post by:
I'm having problems getting the GridView to reliably display a large amount of data (50,000+ rows). I am working my way through the excellent book “Real World ASP.NET Best Practices” by Farhan...
0
7203
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
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
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...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
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...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.