hello,
I'm trying to fill the table named "ALBARANES" which is based on a query. The query use table "structureO K". There are 3 additional values should be updated.
[date] AS Expr2
[Subject] AS Expr3
[Text] AS Expr1
I did this in access2003 and it works but each time I start the query I will be asked to enter a date, subject and text.
Now, I have created a form with textboxes, one for Date, one for Subject and one for text.
by starting the query instead of asking me to enter some values The query should take the data from the texboxes.
Therefore, as you can see below I defined 3 variables as string
str_text;
str_subject;
str_date
I getting in troulble if I try to change the SQL instrucction to include those variables.
Can someone help me out by this problem.
How I have to define the SQL to take the values from the variable?
below You have the code
thanks in advance
regards
logo3
------------------------------------------------------------------------------- -
Dim objDB As DAO.Database
-
Dim objRS As DAO.Recordset
-
Dim strSQL As String
-
-
Dim str_text As String
-
Dim str_subject As String
-
Dim str_date As String
-
-
-
-
-
str_text = gei_texto.Value ' to give the content of textbox (texto) to str_text
-
str_subject = gei_asunto.Value ' to give the content of textbox (asunto) to str_subject
-
str_date = gei_fecha.Value ' to give the content of textbox (fecha) to str_date
-
-
strSQL = "INSERT INTO ALBARANES ( [sales unit], unit, [jvperson], [jzperson], name, street, zipcode, city, city2, country, employee, phone, deliverydate, subject, Text ) SELECT structureOK.[sales unit], structureOK.unit, structureOK.[jvperson], structureOK.[jzperson], structureOK.name, structureOK.street, structureOK.[zipcode], structureOK.city, structureOK.[city2], structureOK.country, structureOK.customer, structureOK.[phone 1], [date] AS Expr2, [subject] AS Expr3, [Text] AS Expr1 FROM structureOK WHERE (((structureOK.unit)='18-000'));"
-
-
-
-
Set objDB = CurrentDb
-
-
Set objRS = objDB.OpenRecordset(strSQL, , DAO.dbSQLPassThrough)
-
-
-
Call objRS.Close
-
Set objRS = Nothing
-
-
Set objDB = Nothing
-------------------------------------------------------------------------
2 9596 NeoPa 32,573
Recognized Expert Moderator MVP
I'm afraid you've made this harder than it needs to be, but I expect that's because there are bits you don't understand too well. Not a problem.
There are two ways to do this & I will doctor your code to show my preferred way (inserting the values from the form directly into your SQL string as literal values). -
Private sub Blah_blah_blah()
-
Dim objDB As DAO.Database
-
Dim objRS As DAO.Recordset
-
Dim strSQL As String
-
-
strSQL = "INSERT INTO ALBARANES (" & _
-
"[sales unit], unit, [jvperson], [jzperson], name, " & _
-
"street, zipcode, city, city2, country, employee, " & _
-
"phone, deliverydate, subject, Text) " & _
-
"SELECT [sales unit], unit, [jvperson], [jzperson], " & _
-
"[name], [street], [zipcode], [city], [city2], " & _
-
"country, customer, [phone 1], " & _
-
Format(Me.gei_fecha,'\#m/d/yyyy\#') & ", " & _
-
"'" & Me.gei_asunto & "', " & _
-
"'" & Me.gei_texto & "' " & _
-
"FROM structureOK " & _
-
"WHERE ([unit]='18-000')"
-
Set objDB = CurrentDb
-
Set objRS = objDB.OpenRecordset(strSQL, , DAO.dbSQLPassThrough)
-
Call objRS.Close
-
Set objRS = Nothing
-
Set objDB = Nothing
-
End Sub
NeoPa 32,573
Recognized Expert Moderator MVP
Remember, the SQL command is simply stored in a string. You prepare the string in advance and if you think of the resultant SQL code as data rather than as part of the coding, it's easier to understand and avoid confusion.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dennis |
last post by:
If I create a database in AccessXP-2000mode, can someone with Access2003 run it?
Do either of us have to do anything special?
Thanks!
Dennis
|
by: Lauren Quantrell |
last post by:
Hoping someonce can tell me what compatibility problems I might run
into when I have to have my Access Project developed on Access2K run
in a user environment where users are using Access2003 as well as
Access2000.
I have already seen a problem where if I open my project using
Access2003 and save any objects, then run it on Access2000, I
encounter "Bad DLL Calling Convention error..." on the Access2K
machines. If I never open and save the...
|
by: Ryan Bounds |
last post by:
Hi All
We have upgraded from Access2000 to Access2003 with all service packs.
The problem that we have is: When a user try's to filter a client the
database crashes and close's Access2003, this is happening on a regular
basis.
We never had this problem in Access2000.
Would it be something to do with code?
|
by: Zlatko Matiæ |
last post by:
Hello.
Could somebody explain the following situation:
I have a .mdb on my notebook with Windows XP SP2 and Access 2003. I prepared
..mde and tried to use it on another computer with Windows XP SP2 and Office
XP installed on it. An error "...Your VBA project is corrupted" appeared.
When I copy .mdb to that computer, instead of .mde, it works. If I then make
the .mde on that computer, it works! If I copy the .mde then to the first...
|
by: 2D Rick |
last post by:
With the help from members in the VB forum I've pieced together code
that works in VB6 to create radial text similar to "text on a path"
seen in graphics programs.(on a circle only)
I use an Access2003 app to gather the data via a barcode reader which
is then concatenated for the radial text.
Is there any possibility that this code can be converted to run in
Access2003?
Option Explicit
| |
by: Vera |
last post by:
I built a class in VB.NET that has an overloaded constructor. It can either accept nothing, a string or an object
Public Sub New(
MyBase.New(
End Su
Public Sub New(ByVal strName As String
MyBase.New(
'... Do init with strNam
End Su
|
by: usenet |
last post by:
How and where can one find out about the basics of VB/Access2003
syntax?
I am a died in the wool C/C++/Java Linux/Unix programmer and I am
finding it difficult to understand the program format for accessing
objects, controls, etc. in VB/Access2003.
In particular where will I find explanations of:-
Actions, Functions, Methods, Properties - I'm understand the
|
by: emlimeng |
last post by:
hi everyone, I need help on an error message. I am working on an environment that Access2003 (adp) as a front end and links to SQL server as a back end.
I am creating a table, which requests users insert a value(varchar) into the table throuth an input box on a form.
Please see the code is below:
Public Sub cmdAdd_Click()
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Dim getStrUR As String
...
|
by: Ramchandar |
last post by:
Hi,
I am creating reports using VBA code.
I have the same query in a querydef residing both in Access97 and Access2003. The result of this querydef is then moved to a table in Access97 and Access2003 respectively. The table in Access97 returns 874 rowcount, table in Access 2003 returns 1050 rowcount. In both the case the querydef is retrieving from the same database which resides in SQL Server 2003.
I executed the application Access97 and...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |