473,324 Members | 2,248 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,324 software developers and data experts.

Input value from VBA module into Access Form

4
Have VBA module that evaluates today’s date and then chooses either end or beginning of month date. Want to hold this date in a form temporarily whilst queries use this date.

How do I write the VBA to put the date into the form please?

B
Mar 5 '07 #1
6 3929
Rabbit
12,516 Expert Mod 8TB
Simpler to just hold it in a global variable.
Mar 5 '07 #2
blip
4
Thanks for your interest. Have done that now but having trouble getting the query to pull that variable when I run it. What should I be putting in the Query Field to get that variable?

I know the VBA works ‘cause I ran it in XL with a message box and it returns the correct value.

B
Mar 6 '07 #3
Rabbit
12,516 Expert Mod 8TB
You'll need to declare it as a public variable in a standard module, that is a non-form non-report module. Then you should be able to call it just by using its name.
Mar 6 '07 #4
ADezii
8,834 Expert 8TB
Thanks for your interest. Have done that now but having trouble getting the query to pull that variable when I run it. What should I be putting in the Query Field to get that variable?

I know the VBA works ‘cause I ran it in XL with a message box and it returns the correct value.

B
Even though you've Declared it as a Public Variable in a Standard Module, and Initialized it, you may still have to Qualify it with the Date Qualifier (#) as in:
Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM Employees Where [BirthDate] = " & "#" & MyDate & "#"
Mar 6 '07 #5
NeoPa
32,556 Expert Mod 16PB
Even though you've Declared it as a Public Variable in a Standard Module, and Initialized it, you may still have to Qualify it with the Date Qualifier (#) as in:
Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM Employees Where [BirthDate] = " & "#" & MyDate & "#"
For a public item to be available to the SQL engine, it cannot simply be defined as a variable. This can be used in the way ADezii's shown (Literal DateTimes and Their Delimiters (#). for fuller info on that), but not natively in the SQL string.
SQL can handle function calls natively though. If you defined a Public Function to return your value then this can be used as a reference within the SQL string itself as shown :
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM Employees
  3. Where [BirthDate]=MyDate()"
Mar 8 '07 #6
blip
4
Thank you all for helping me out, it’s really appreciated. I used:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3. Private m_nAcctYear As Integer
  4. Public Function setAcctYear(nYear As Integer)
  5.    m_nAcctYear = nYear
  6. End Function
  7. Public Function getAcctYear( ) As Integer
  8.    getAcctYear = m_nAcctYear
  9. End Function
  10. ------------------------------
  11. Example SQL statement:
  12. SELECT *
  13. FROM DeptSales
  14. WHERE (DeptSales.AcctYear = getAcctYear( ));
  15.  
to solve it. Thanks again.
Mar 8 '07 #7

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

Similar topics

3
by: Emanuel Marciniak | last post by:
Hi all, We have the form which uses checkboxes for several fields and the target action points to outside webservice. Unfortunatelly they do not support checkboxes. How to pass it as a radio...
1
by: LC's No-Spam Newsreading account | last post by:
I have the following arrangement working under Netscape 3 / Unix, IE6 / Win and Konqueror / Linux, but NOT under Netscape 7 Unix or Mozilla Linux (silently fails) nor under Netscape 4 Unix (fails...
1
by: Brian Genisio | last post by:
Hi all, I noticed that the image input type does not show up in the elements array (IE 6.0). <FORM name=myForm> <INPUT name=rads id=check1 type=radio value=val1> <INPUT name=rads id=check2...
4
by: multimatum2 | last post by:
Hello, I need to enable/disable input text forms... But... I need to have the same style (color...) in both modes.. Could you help me ? Thanx a lot A small sample... ...
8
by: PerryC | last post by:
I want to be able to accomplish this, please help: When click on the DOB field, a ActiveX Calender popup and the user choose a date, the value is automatically refreshed in the DOB field in the...
4
by: David W. Fenton | last post by:
I'm working on a subform where users put in 24-hour time. On their paper forms, they've been accustomed to referring to midnight as 24:00 (instead of as 0:00, which kind of makes sense from a human...
13
by: Richard Hollenbeck | last post by:
To prevent future apostrophe bugs and errors, isn't it just simpler to forbid an apostrophe from being entered into a text field? For example, couldn't "Alice's Restaurant" be changed to "Alices...
3
by: jackiepatti | last post by:
QUESTION: I have a web page containing a form that contains an image instead of a submit button, e.g. <form name='myform' action='get' method='otherpage.asp'> <input type='image'...
5
by: hrpreet | last post by:
Hi All, I need the file chooser in the jsp, just for brosing and saving the file path in the database, so i have used the following code.I dont need to read the file content. I have to make it...
1
by: anon1m0us | last post by:
Hi; I am waaayyy new at ASP so I am hopping someone can help me. I wrote an ASP that accepts input from a user. I need the input saved in different cells in an excel sheet. Everytime someone hits...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.