Can anyone help me with VBA code for selecting the value of a field in a record and storing it as a variable I can then INSERT INTO another table. I will also want to use this variable to rename a file. eg. sample.txt with become sample091506.txt. The info I need to grab is a date that is stored in a field called [LocateDate]. Thanks for any help!
6 2154
Should I use a SELECT DISTINCT statement? I keep getting Data Type Mismatch because the value I want is a DATE. My Statement reads
Dim TempDate as DATE
SELECT DISTINCT MarketDataTemp.LocateDate AS TempDate FROM MarketDataTemp
PEB 1,418
Expert 1GB
Should I use a SELECT DISTINCT statement? I keep getting Data Type Mismatch because the value I want is a DATE. My Statement reads
Dim TempDate as DATE
SELECT DISTINCT MarketDataTemp.LocateDate AS TempDate FROM MarketDataTemp
1. So to have a Global Variable use:
Global TempDate
in a module! If you don't want to be global you can use in your Form
Dim TempDate
2. To set the variable after updating event your field LocateDate:
TempDate=MarketDataTemp.LocateDate
3. In your SQL: SELECT DISTINCT MarketDataTemp.LocateDate AS TempDate FROM MarketDataTemp you need to put ; at the end
4. to create your file name use
[my_file_name]=Mid([my_file_name],1,Len([my_file_name])-4)+TempDate+".txt"
:)
1. So to have a Global Variable use:
Global TempDate
in a module! If you don't want to be global you can use in your Form
Dim TempDate
2. To set the variable after updating event your field LocateDate:
TempDate=MarketDataTemp.LocateDate
3. In your SQL: SELECT DISTINCT MarketDataTemp.LocateDate AS TempDate FROM MarketDataTemp you need to put ; at the end
4. to create your file name use
[my_file_name]=Mid([my_file_name],1,Len([my_file_name])-4)+TempDate+".txt"
:)
Thank you for your help. So that I understand, to obtain the date value from tbl#1 and then add a new record to tbl#2 with this value, I would use the code:
Dim TempDate
SELECT DISTINCT MarketDataTemp.LocateDate AS TempDate FROM MarketDataTemp
docmd.runSQL "INSERT INTO tbl#2 DateField,NoOfZeros VALUES TempDate, 60"
PEB 1,418
Expert 1GB
Oppa,
In fact no! Sorry with those codes i've not understand what did you mean! -
Dim TempDate
-
tempdate=dfirst("LocateDate", "MarketDataTemp","")
-
docmd.runSQL "INSERT INTO tbl#2 (DateField,NoOfZeros) VALUES (CVDATE('"& str(TempDate) & "'), 60)"
-
:)
If pb here we are...
Thank you for your help. So that I understand, to obtain the date value from tbl#1 and then add a new record to tbl#2 with this value, I would use the code:
Dim TempDate
SELECT DISTINCT MarketDataTemp.LocateDate AS TempDate FROM MarketDataTemp
docmd.runSQL "INSERT INTO tbl#2 DateField,NoOfZeros VALUES TempDate, 60"
Oppa,
In fact no! Sorry with those codes i've not understand what did you mean! -
Dim TempDate
-
tempdate=dfirst("LocateDate", "MarketDataTemp","")
-
docmd.runSQL "INSERT INTO tbl#2 (DateField,NoOfZeros) VALUES (CVDATE('"& str(TempDate) & "'), 60)"
-
:)
If pb here we are...
Thank you so much for your help!! It worked great!
PEB 1,418
Expert 1GB
:)
Have a nice eveneing!
:)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mark |
last post by:
Hi - I have set-up security for my users - the security is held in a
text field, separated by a comma.
If the users a member of groups 1, 5 and 6 - the usergroups field is set
to 1,5,6 - to...
|
by: Kevin Lyons |
last post by:
Hello,
I am trying to get my select options (courses) passed correctly from
the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html
I am having difficulty getting the...
|
by: tedhekman |
last post by:
Hi there! I am pretty new to Access, have been loving learning it! I
have a problem here I can't even begin to figure out. Here is what I
need:
Given 1 Date and 1 Store, retrieve the following...
|
by: Nathan Sokalski |
last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an...
|
by: robecflo |
last post by:
Hi Forum, i have a problem, hope somebody can give me ideas. I'm
developing with windows forms and vb.net, and oracle as a database. At
this moment i have a table called amortizaciones, this table...
|
by: Brad |
last post by:
get the following error when I try to save a date:
When converting a string to DateTime, parse the string to take the date
before putting each variable in the DateTime object.
I was using a...
|
by: jjturon |
last post by:
Can anyone help me??
I am trying to pass a Select Query variable to a table using Dlookup
and return the value to same select query but to another field.
Ex.
SalesManID ...
|
by: Sunray |
last post by:
I have a form called the sales form and i have 2 sets of listboxes
So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
|
by: sbettadpur |
last post by:
Hello everybody
I have some issues in my program.
Let me explain my requirement briefly, i am using php, mysql, javascript and ajax for my application.
when my application opens means if...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
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...
| |