473,395 Members | 2,222 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.

Using code in VBA pulled from database

I have a date range selection drop down list. I want the user to be able to pick options such as Today, Yesterday, This Month, Last Month, and have two date fields below the drop down populate with the appropriate dates. I have two columns in the table used to display the date range name, DateStart, DateEnd. In each I have some code such as =Date() for Today. I can get some simple VBA code to pull =Date() out and put it into the text box, but it comes in as plain text. I want the result of =Date() instead. How can I force VBA to evaluate my code snippet and return the resulting value to the text box? Or am I doing things the hard way and should just hard code this into the form's VBA?
Feb 15 '08 #1
1 1258
Stewart Ross
2,545 Expert Mod 2GB
I have a date range selection drop down list. I want the user to be able to pick options such as Today, Yesterday, This Month, Last Month, and have two date fields below the drop down populate with the appropriate dates. I have two columns in the table used to display the date range name, DateStart, DateEnd. In each I have some code such as =Date() for Today. I can get some simple VBA code to pull =Date() out and put it into the text box, but it comes in as plain text. I want the result of =Date() instead. How can I force VBA to evaluate my code snippet and return the resulting value to the text box? Or am I doing things the hard way and should just hard code this into the form's VBA?
Hi. I'm not sure what the problem is here - perhaps you can provide more details of the code you use so we can see what is going on?

Text boxes themselves don't 'know' anything about types - they are just a means to collect and pass on characters typed by the user or displayed from underlying tables/VBA etc. Type conversion takes place on the fly, as bound fields have specific types, and unbound fields have implied types when used in numeric calculations, for example.

When you display a date value in a text box it is really just text, not a date in the way that Access actually stores dates (as date/time numeric values where the Long Integer part is the date and the decimal component the time). Hence why I'm not sure what is causing you difficulties - are you trying to compare the user-selected values with other fields and finding that it doesn't work because they are really text? If you are you will need to convert the value to a date explicitly, using the CDate function to do so.

With CDate([text box reference]) you can be sure that you are using a date, not a text value, in any comparison or range test.

By the way, the fact that text representations of dates are not dates is why you have to place hashes around specific references to dates in the criterion line of an Access query - #15/02/2008# - as this tells the query engine to treat the reference as a date, not text.

If you need more assistance I'd be glad to help if you could expand a bit on the code you are trying to use.

Regards

Stewart
Feb 15 '08 #2

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

Similar topics

14
by: David Lozzi | last post by:
OK, I know how to use to pull up all records that contains the keyword, but what about not containing the keyword? I've tried NOT LIKE but i get Arguments are of the wrong type, are out of...
9
by: BCS | last post by:
I have a web site in which the site administrator can input information to a database through a web form. The information then gets displayed on ASP pages. One field is a large text field. Of...
7
by: chriskoch | last post by:
I am running a DTS Package. I have a temp table with 1494 records. I am inserting a 'Y' or 'N'into a temp table #HasClaims. The TempTable name with the Provider Id's(PRPR_ID) is...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
3
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am...
5
by: Haydnw | last post by:
Hi, I have the code below as code-behind for a page which displays two images. My problem is with the second bit of code, commented as " 'Portfolio image section". Basically, the SQL query gets...
21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
45
by: Luvin lunch | last post by:
Hi, I'm new to Access and have been asked to develop a simple Access system to replace one that already exists. There are five users of the current Access system and each of the users works off...
11
by: S N | last post by:
how to print apostrophe character ' and double quote " in asp using vbscript. my code using response.write replaces " character with inverted question mark. please help
2
by: Andy B | last post by:
I have a database with asp.net membership inside it. How would I use it for 2 or more web applications at the same time?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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
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.