Hi, this is my first attempt to create variables to assign a value, so thanks for any suggestions.
I have a field in a form I'd like to match a substring of to another table and insert. The problem is in retrieving the value. It pops a window where if I put in the AcctNumb value it works, but this is obviously not right. My code is:
Private Sub FinishBtn_Click ()
Dim AcctSysprin As String
AcctSysprin = "Forms![FrmEsc4Disp]![AcctNumb].Value"
AcctSysprin = Left(AcctSyspri n, 8)
Dim AcctCitySQL As String
AcctCitySQL = "INSERT INTO TblDateContact"
AcctCitySQL = AcctCitySQL + " (FldCity)"
AcctCitySQL = AcctCitySQL + " SELECT FldMarket"
AcctCitySQL = AcctCitySQL + " FROM TblMarket"
AcctCitySQL = AcctCitySQL + " WHERE FldSysprin = AcctSysprin"
DoCmd.SetWarnin gs True
DoCmd.RunSQL AcctCitySQL
DoCmd.Save
DoCmd.GoToRecor d , , acNewRec
End Sub
6 1935 ADezii 8,834
Recognized Expert Expert
Hi, this is my first attempt to create variables to assign a value, so thanks for any suggestions.
I have a field in a form I'd like to match a substring of to another table and insert. The problem is in retrieving the value. It pops a window where if I put in the AcctNumb value it works, but this is obviously not right. My code is:
Private Sub FinishBtn_Click ()
Dim AcctSysprin As String
AcctSysprin = "Forms![FrmEsc4Disp]![AcctNumb].Value"
AcctSysprin = Left(AcctSyspri n, 8)
Dim AcctCitySQL As String
AcctCitySQL = "INSERT INTO TblDateContact"
AcctCitySQL = AcctCitySQL + " (FldCity)"
AcctCitySQL = AcctCitySQL + " SELECT FldMarket"
AcctCitySQL = AcctCitySQL + " FROM TblMarket"
AcctCitySQL = AcctCitySQL + " WHERE FldSysprin = AcctSysprin"
DoCmd.SetWarnin gs True
DoCmd.RunSQL AcctCitySQL
DoCmd.Save
DoCmd.GoToRecor d , , acNewRec
End Sub
Try: - Private Sub FinishBtn_Click()
-
Dim AcctSysprin As String
-
AcctSysprin = Forms![FrmEsc4Disp]![AcctNumb]
-
AcctSysprin = Left$(AcctSysprin, 8)
-
-
Dim AcctCitySQL As String
-
AcctCitySQL = "INSERT INTO TblDateContact"
-
AcctCitySQL = AcctCitySQL & " (FldCity)"
-
AcctCitySQL = AcctCitySQL & " SELECT FldMarket"
-
AcctCitySQL = AcctCitySQL & " FROM TblMarket"
-
AcctCitySQL = AcctCitySQL & " WHERE FldSysprin = '" & AcctSysprin & "'"
-
-
DoCmd.SetWarnings True
-
DoCmd.RunSQL AcctCitySQL
-
DoCmd.Save
-
DoCmd.GoToRecord , , acNewRec
-
End Sub
Thanks! I'm getting a Data Type Mismatch error...? Try: - Private Sub FinishBtn_Click()
-
Dim AcctSysprin As String
-
AcctSysprin = Forms![FrmEsc4Disp]![AcctNumb]
-
AcctSysprin = Left$(AcctSysprin, 8)
-
-
Dim AcctCitySQL As String
-
AcctCitySQL = "INSERT INTO TblDateContact"
-
AcctCitySQL = AcctCitySQL & " (FldCity)"
-
AcctCitySQL = AcctCitySQL & " SELECT FldMarket"
-
AcctCitySQL = AcctCitySQL & " FROM TblMarket"
-
AcctCitySQL = AcctCitySQL & " WHERE FldSysprin = '" & AcctSysprin & "'"
-
-
DoCmd.SetWarnings True
-
DoCmd.RunSQL AcctCitySQL
-
DoCmd.Save
-
DoCmd.GoToRecord , , acNewRec
-
End Sub
Thanks! I'm getting a Data Type Mismatch error...?
OK, I've corrected the table data type, but still getting " Syntax Error (Missing Operator) in query expression 'FldSysprin=' "
Any Ideas? Thanks again for your help.
ADezii 8,834
Recognized Expert Expert
OK, I've corrected the table data type, but still getting " Syntax Error (Missing Operator) in query expression 'FldSysprin=' "
Any Ideas? Thanks again for your help.
Change Line #11 in Post #3 to: - 'Syntax is different since value is Numeric
- AcctCitySQL = AcctCitySQL & " WHERE FldSysprin = " & AcctSysprin
-
Progress! Runs without errors, but says "Updating 0 rows" and nothing populates...I appreciate the suggestions.
ADezii 8,834
Recognized Expert Expert
Progress! Runs without errors, but says "Updating 0 rows" and nothing populates...I appreciate the suggestions.
That's because - "SELECT FldMarket FROM TblMarket WHERE FldSysprin = " & AcctSysprin
returns no Records. Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Alistair |
last post by:
Hi all,
I am creating a database based site that keeps track of books, who has read
them and the comments they have.
After a little help in M.P.I.asp.DB I managed to create a database (access
2000) as follows
USERS TABLE
|
by: Dave Hopper |
last post by:
Hi
I am using the following SQL to retrieve a value in a list box using a
unique ID held in the list box call cntID. The list box is used on an
order form to list appointments that have been made for service staff.
My problem is the SQL is not retrieving the value of the listbox. I
have tested the SQL by entering a fixed value of a valid entry in the
listbox and it works fine, but as soon as I replace the fixed value
with...
|
by: aniket_sp |
last post by:
i am using a data adapter and a dataset for filling and retrieving data
into .mdb database.
following is the code.....
for the form load event
Dim dc(0) As DataColumn
Try
If OleDbConnection1.State = ConnectionState.Closed Then
OleDbConnection1.Open()
Else
|
by: Sirplaya |
last post by:
I am retrieving images that I stored in SQL Server on my web pages in C#. I
have no problem with the images displaying, however, I am trying to wrap the
image with an <A HREF ..." and each time I try, it acts like the link is not
even on the image.
What is the proper way to do this?
Thanks.
|
by: jimmyfo |
last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published
(using VS2005 Publish feature) it to a relatively clean machine with
ASP.Net 2.0 and MDAC 2.8 installed on it. However, when I try to create
my SQL connection in the code-behind, I get the following error. I
tried to register the DLL using regsvr32 but that errored out saying,
"dllregisterserver entry point was not found". Any ideas?
Retrieving the COM class factory...
| |
by: 4Ankit |
last post by:
hello all, i am having some difficulty retrieving information from my
form. I want to add content in my table but the content i want to add
to the table is what the user inputs in my form.
Basically i want to know how i retrieve information from the form so i
can disaply it in the table.
i have put the code i am using below, the feature i cannot get to work
is the change content function. I want the email address entered by
the...
|
by: Sanjay Pais |
last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time
using the with - over clauses
In query analyser, the data is retrieved in under a second.
When retrieving using the data adaptor.fill or datareader to retrieve the
data it takes over 24 seconds.
public System.Data.SqlClient.SqlDataReader List1(int PageIndex, int
PageSize, string ItemName, string UserIDs, DateTime DateStart, DateTime
DateEnd, int status,...
|
by: bmallett |
last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options within options. I have everything being dynamically named from the previously dynamically named element. (I hope this makes sense.) I am not able to retrieve any of the dynamically created values. I can view them on the source page but can't pull them...
|
by: san123456789 |
last post by:
Hi,
Im using a MS SQL server to store images... Im creating a windows form application using C#.
I need to store and retrieve images from the database.
This is my code to store images:
pictureBox.Image = new System.Drawing.Bitmap(this.openFileDialog.FileName);
|
by: vpriya6 |
last post by:
Hi guys,
I am new to Ajax, xml and javascript.
I want to know how can I retrieve data from xml and display in the html page?
please help me out.
suppose my xml file is customer.xml the code is below:
<CUSTOMER>
|
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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: 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: 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...
| |