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

Help with code

Hi All,

Access 2002 using Windows XP

I am pretty new to writing code so please bear with me. I have some code
which exectues an append and a select query. Both queries require the user
to enter a date. Becaue of this, the same information has to be entered
twice which I would like to avoid.

Is there a way using code, that I can prompt the user to enter the date and
save their input as a variable? I'm assuming that by doing it this way, I
can run the SQL's from within the code and use the stored variable as the
SQL criteria rather than calling the stored queries?

Or maybe there's a completly better/easier way?

Any help on this would be much appreciated.

Regards,

Mark

Nov 13 '05 #1
6 2576
Provide a little unbound form where the user can enter the values.

In the Criteria row of your query, you can refer to:
[Forms].[Form1].[Textbox1]
or if you execute the query in code, you can concatenate the value of the
text box into the string.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mark" <ma*********@ntlworld.com> wrote in message
news:x7*************@newsfe6-gui.ntli.net...
Hi All,

Access 2002 using Windows XP

I am pretty new to writing code so please bear with me. I have some code
which exectues an append and a select query. Both queries require the user
to enter a date. Becaue of this, the same information has to be entered
twice which I would like to avoid.

Is there a way using code, that I can prompt the user to enter the date
and save their input as a variable? I'm assuming that by doing it this
way, I can run the SQL's from within the code and use the stored variable
as the SQL criteria rather than calling the stored queries?

Or maybe there's a completly better/easier way?

Any help on this would be much appreciated.

Regards,

Mark

Nov 13 '05 #2
"Mark" <ma*********@ntlworld.com> wrote:
Or maybe there's a completly better/easier way?


Hi Mark.

One approach would be to have your users input the reuired value into a
text box on a (dialogue) form and then reference the text box in your
stored query's criteria, ie in query grid's criteria line for the field in
question, enter [Forms]![MyForm]![txtMyTextBox] (where "MyForm" is the name
of the form and "txtMyTextBox" is the name of the text box).

If you enter this into both queries and call the queries from code whilst
"MyForm" is open, then that should work.

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #3
Thankyou both for your quick response.

I understand what you are saying about using the unbound form to retrieve
the value but what I dont get how to do is open the form mid way through my
code when I need it, pause the code until the information has been input on
the form and then resume the code where I can then reference their input???

Thanks again,

Mark

"Mark" <ma*********@ntlworld.com> wrote in message
news:x7*************@newsfe6-gui.ntli.net...
Hi All,

Access 2002 using Windows XP

I am pretty new to writing code so please bear with me. I have some code
which exectues an append and a select query. Both queries require the user
to enter a date. Becaue of this, the same information has to be entered
twice which I would like to avoid.

Is there a way using code, that I can prompt the user to enter the date
and save their input as a variable? I'm assuming that by doing it this
way, I can run the SQL's from within the code and use the stored variable
as the SQL criteria rather than calling the stored queries?

Or maybe there's a completly better/easier way?

Any help on this would be much appreciated.

Regards,

Mark

Nov 13 '05 #4
Lots of solutions, but try this:

In your code, before the queries are run:
DoCmd.OpenForm "MyForm", WindowMode:=acDialog
That pauses the code until the user dismisses the dialog.

Now in the Ok button of the form:
Me.Visible = False
This hides the dialog from the user, but leaves it open for your code to
read.

At the end of your code:
DoCmd.Close acForm, "MyForm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mark" <ma*********@ntlworld.com> wrote in message
news:fI*************@newsfe4-gui.ntli.net...
Thankyou both for your quick response.

I understand what you are saying about using the unbound form to retrieve
the value but what I dont get how to do is open the form mid way through
my code when I need it, pause the code until the information has been
input on the form and then resume the code where I can then reference
their input???

Thanks again,

Mark

"Mark" <ma*********@ntlworld.com> wrote in message
news:x7*************@newsfe6-gui.ntli.net...
Hi All,

Access 2002 using Windows XP

I am pretty new to writing code so please bear with me. I have some code
which exectues an append and a select query. Both queries require the
user to enter a date. Becaue of this, the same information has to be
entered twice which I would like to avoid.

Is there a way using code, that I can prompt the user to enter the date
and save their input as a variable? I'm assuming that by doing it this
way, I can run the SQL's from within the code and use the stored variable
as the SQL criteria rather than calling the stored queries?

Or maybe there's a completly better/easier way?

Any help on this would be much appreciated.

Regards,

Mark

Nov 13 '05 #5
"Mark" <ma*********@ntlworld.com> wrote:
what I dont get how to do is open the form mid way through my
code when I need it, pause the code until the information has been
input on the form and then resume the code where I can then reference
their input?


It's difficult to say without more info, but at a guess, can you initiate
the code from an OK button on the form you use to collect the user input?
It doesn't actually matter when you collect the user input as long as the
form is still open when the queries run. The code in your OK button could
be along the lines of:

Call MyProcedure 'This runs the queries
DoCmd.Close acForm, Me.Name

Regards,
Keith.
Nov 13 '05 #6
I cannot thank you both enough. The code works exactly how I want it to now
and that is one less headache I have to deal with.

Thanks again,

Mark

"Mark" <ma*********@ntlworld.com> wrote in message
news:fI*************@newsfe4-gui.ntli.net...
Thankyou both for your quick response.

I understand what you are saying about using the unbound form to retrieve
the value but what I dont get how to do is open the form mid way through
my code when I need it, pause the code until the information has been
input on the form and then resume the code where I can then reference
their input???

Thanks again,

Mark

"Mark" <ma*********@ntlworld.com> wrote in message
news:x7*************@newsfe6-gui.ntli.net...
Hi All,

Access 2002 using Windows XP

I am pretty new to writing code so please bear with me. I have some code
which exectues an append and a select query. Both queries require the
user to enter a date. Becaue of this, the same information has to be
entered twice which I would like to avoid.

Is there a way using code, that I can prompt the user to enter the date
and save their input as a variable? I'm assuming that by doing it this
way, I can run the SQL's from within the code and use the stored variable
as the SQL criteria rather than calling the stored queries?

Or maybe there's a completly better/easier way?

Any help on this would be much appreciated.

Regards,

Mark


Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
6
by: d.warnermurray | last post by:
I am doing a project for school that involves creating help files for a html authoring tool. If you could help me with answers to some questions it would really help. 1. What tasks do you expect...
6
by: Mark Reed | last post by:
Hi all, I am trying to learn a little about programming (I know next to nothing so far) and have found some code which hides the toolbars. However, this bit of code is a little too effective and...
4
by: dixie | last post by:
Help, I'm really out of my depth here (not unusual I hear you say :-). I have just installed HTML Help in an application. I told it in the Project Properties the path to the help file. I then...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
16
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just...
3
by: inkexit | last post by:
I need help figuring out what is wrong with my code. I posted here a few weeks ago with some code about creating self similar melodies in music. The coding style I'm being taught is apparently a...
1
by: glenn123 | last post by:
Hi, i am just about out of time to produce a working jukebox which has to perform these functions: to play music files when a track is chosen from a list which when the user presses the change genre...
10
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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,...

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.