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

Setting query criteria in a form and running a query from that form by pressing a cmd

Hello everyone. I am somewhat new to access and this forum. Hopefully it will be a great and helpful experience.

My problem is this. I have a database (about 65,000 records).

I get a run from another party every month in a text format (notepad) which I import into my database and make a comparison between the previous months and current months tables (some fields) by running a query. What I am trying to do is create a nice form that will

a) have an option to import the the file automatically (it gets updated every month in a file on the local network [same name] now I have it linked and when it changes I run a query and save the table as the new month) I want to automate that. (if possible)

b) have a form that will alow me to enter different data (criteria) and after pressing a cmd button it will run a query for me. (This is most important) I tried to do something and something really crazy began to happen.

c) export or save that run to a specific folder and chosen name. (i do not know if it is possible, again automatically)
Whoever can, please help. All advice and help is very much appreciated in advance.

Thanks
-Arthur
Oct 30 '06 #1
25 3809
By the way, it is sort of like a Find A Person. In other words, if I enter many different criteria, it will give me the results in a separate form. If I enter a unique criteria, say Social Sec #, then it will pull up all the needed information just about that 1 person. Thank you alll so much..........plz help :-(

Hello everyone. I am somewhat new to access and this forum. Hopefully it will be a great and helpful experience.

My problem is this. I have a database (about 65,000 records).

I get a run from another party every month in a text format (notepad) which I import into my database and make a comparison between the previous months and current months tables (some fields) by running a query. What I am trying to do is create a nice form that will

a) have an option to import the the file automatically (it gets updated every month in a file on the local network [same name] now I have it linked and when it changes I run a query and save the table as the new month) I want to automate that. (if possible)

b) have a form that will alow me to enter different data (criteria) and after pressing a cmd button it will run a query for me. (This is most important) I tried to do something and something really crazy began to happen.

c) export or save that run to a specific folder and chosen name. (i do not know if it is possible, again automatically)
Whoever can, please help. All advice and help is very much appreciated in advance.

Thanks
-Arthur
Oct 30 '06 #2
MMcCarthy
14,534 Expert Mod 8TB

a) have an option to import the the file automatically (it gets updated every month in a file on the local network [same name] now I have it linked and when it changes I run a query and save the table as the new month) I want to automate that. (if possible)
When you import the file next click on the advanced tab in the wizard and save an import specification file (remember the name).

Then you can code the following behind a command button

Expand|Select|Wrap|Line Numbers
  1.  
  2. DoCmd.TransferText acImportDelim, "Name of Specification File", "TableName", "Full path to file", True
  3.  
  4.  
acImportDelim - means that the text file has commas (or something else) separating the values. If the file is Fixed Length then acImportFixed

Name of Specification File - As above

TableName - is the name of the table you want to import to

Full path to file - e.g. "C:\My Documents\sample.txt"

True - Means the file has field names on the first line (False if it doesn't)



b) have a form that will alow me to enter different data (criteria) and after pressing a cmd button it will run a query for me. (This is most important) I tried to do something and something really crazy began to happen.
Explain further what your query is ... and what the fields on the form are called and what values they represent. If you have a sample query or piece of code post it here.


c) export or save that run to a specific folder and chosen name. (i do not know if it is possible, again automatically)
Its very similar to the import above. Do an export and click on advanced tab and save an export specification.

Expand|Select|Wrap|Line Numbers
  1.  
  2. DoCmd.TransferText acExportDelim, "Name of Specification File", "TableName", "Full path to file", True
  3.  
  4.  
Oct 30 '06 #3
Thank you for the help.! :-)

Although I am still quite lost, I need the form to be linked to a query where instead of me entering criteria into the design view of a query, I can use the input text boxes to enter the criteria and click a cmd button "Search" and the query will run. I am creating a more user friendly environment so that people other than me can use this at work without knowing much abouit access. I think it would be very helpful and beneficial to them. So basically my query is quite complicated. It has many criteria (although I just need the basic way to link the criteria into a forms text box and create a button that will run the query. the rest I hope I will figure out.

Thanks
Oct 31 '06 #4
southoz
24
Good ay ,

not sure if this is what u mean but it may help
i have a few fields on a form and a query for statements an invoices , on clicking a command button it open an invisible form that runs a query connected to a listbox

SELECT DISTINCT statement.OrderNumber,statement.clientname,stateme nt.pickupdate,statement.subprice,statement.orderwe ek FROM statement WHERE [statement.orderweek] = Forms![Orders1]![orderweek] AND [statement.clientname] = Forms![Orders1]![clientname] ;

the first few fields seperated with comers indicate the fields in the query i'm after the from statement (statement being the query itself) where the fields in the statement = whats on the main form AND as the second part of where > so if your looking for multi arguments for the query u can try that

hope it help a little
southoz
Oct 31 '06 #5
Thanks, but where am I suppose to write the statement that you gave me: beginning with the select distict. Would it be possible for you to e-mail me the db with this example? I think it is something that I can use to build on?
If you can and dont have much info there that you cannot share (which I dont need) that would be cool. my e-mail is: ArtRomanov "AT" gmail "DOT" com

Thanks for your help.

Good ay ,

not sure if this is what u mean but it may help
i have a few fields on a form and a query for statements an invoices , on clicking a command button it open an invisible form that runs a query connected to a listbox

SELECT DISTINCT statement.OrderNumber,statement.clientname,stateme nt.pickupdate,statement.subprice,statement.orderwe ek FROM statement WHERE [statement.orderweek] = Forms![Orders1]![orderweek] AND [statement.clientname] = Forms![Orders1]![clientname] ;

the first few fields seperated with comers indicate the fields in the query i'm after the from statement (statement being the query itself) where the fields in the statement = whats on the main form AND as the second part of where > so if your looking for multi arguments for the query u can try that

hope it help a little
southoz
Oct 31 '06 #6
MMcCarthy
14,534 Expert Mod 8TB
Firstly, if you are giving your email don't write it correctly write it like this

ArtRomanov "AT" gmail "DOT" com

Sites like this get trawled on a regular basis looking for legitimate email addresses.



Explain further what your query is ... and what the fields on the form are called and what values they represent. If you have a sample query or piece of code post it here.
I do understand what you are trying to do which is why I asked that you post your query as it stands at the moment along with a list of the criteria you want the user to be able to enter. I can't help without that.
Oct 31 '06 #7
MMcCarthy
14,534 Expert Mod 8TB
Firstly, if you are giving your email don't write it correctly write it like this

ArtRomanov "AT" gmail "DOT" com

Sites like this get trawled on a regular basis looking for legitimate email addresses.
I've changed your post accordingly by the way ...
Oct 31 '06 #8
Instead of replying, I have accidently REPORTED that message (which took me about 30 minutes to write) Oh no. If you are the moderator (or admin,can you please check your report messages?) I am so sorry.
Thank you.
I've changed your post accordingly by the way ...
Oct 31 '06 #9
MMcCarthy
14,534 Expert Mod 8TB

This is the message that was posted ...
Thank you kindly. I have no clue how to paste the query. It is in design view (there is no programming or SQL where statements. (I dont even know how to use them)

Basically this is how it is formed. I have many tables that relate to one another based on many different codes. e.g. Budget Code, Payroll Distribution Code and so on... (about 20 different codes) There are 65,000 emplyees listed (many of them twice) because of changes made to their profile that are saved as and now overwritten. Every month, I get a new file with updated information about the employees. (The 65000 are employees dated like 20 years) So, there are only about 8,000 ACTIVE employees with a leave status B. What I do is compare, using a query last months and this months roster based on changes in their leave status (everyone going from a B to an A) as an example, the criteria set for August - September is : <>[September Employee Roster]![Leave] <-- this is written in the criteria of the August table:

What I would love access to do is do this automatically or semi automatically. Import the file, set up the query and run after I press a button.

This i believe would be impossible (atleast for me to do) but what is possible is the following:

I use this DB for other purposes also. I would like to create a form where a query will exist (in the background) and after I input some criteria (into the text fields) of the form and press a button, then the query will run and return results. Basically I want to make a search feature that will pull out records after I enter the criteria on a form instead of in design mode in a query. See if you understand what I mean. Basically for now, I just want to create a search feature.

P.S. Where do you write the where statements and syntax?Thanks
Oct 31 '06 #10
MMcCarthy
14,534 Expert Mod 8TB
Thank you kindly. I have no clue how to paste the query. It is in design view (there is no programming or SQL where statements. (I dont even know how to use them)
Open the query in design view and then change the view to SQL. Just copy and paste it here.
Oct 31 '06 #11
Thats pretty cool. Here is what I have.

SELECT [September Employee Roster].SS, [September Employee Roster].[Title Code], Title_codes.Decription, [September Employee Roster].[Last Name], [September Employee Roster].[First Name], [August Employee Roster].Leave, [September Employee Roster].Leave, Leave_Codes.[Leave Description], [September Employee Roster].BC, [September Employee Roster].BL, [September Employee Roster].Paycode, Pyrl_Dist_Codes.[WORK UNIT], Pyrl_Dist_Codes.[WORK UNIT DESC], Pyrl_Dist_Codes.[GEO LOC DESC], [September Employee Roster].[Salary/Rate], [September Employee Roster].Decimal, [September Employee Roster].[Emhist Date]
FROM (Title_codes INNER JOIN [August Employee Roster] ON Title_codes.[Title Code] = [August Employee Roster].[Title Code]) INNER JOIN (Leave_Codes INNER JOIN ([September Employee Roster] LEFT JOIN Pyrl_Dist_Codes ON [September Employee Roster].Paycode = Pyrl_Dist_Codes.PAYCODE) ON Leave_Codes.Leave = [September Employee Roster].Leave) ON ([August Employee Roster].SS = [September Employee Roster].SS) AND ([August Employee Roster].[First Name] = [September Employee Roster].[First Name]) AND ([August Employee Roster].[Last Name] = [September Employee Roster].[Last Name])
WHERE ((([September Employee Roster].[Title Code])<>80633) AND (([August Employee Roster].Leave)<>[September Employee Roster]![Leave]) AND (([September Employee Roster].Leave)="A") AND (([September Employee Roster].BL) Not Like "6***") AND (([September Employee Roster].Paycode) Not Like "******2" And ([September Employee Roster].Paycode) Not Like "******4" And ([September Employee Roster].Paycode) Not Like "******6") AND (([September Employee Roster].[Emhist Date]) Like "200609**") AND (([September Employee Roster].SeqNum)=1)) OR ((([September Employee Roster].Leave)="U"))
ORDER BY [September Employee Roster].[Last Name], [September Employee Roster].Leave;
Oct 31 '06 #12
MMcCarthy
14,534 Expert Mod 8TB
Lets just look at the where statement as I assume this is where you want the user criteria to be used.

If for instance you set up a text box on the form called txtTitleCode for the user to enter the Title Code.

you could change this part of the statement to:

Expand|Select|Wrap|Line Numbers
  1.  
  2. WHERE ((([September Employee Roster].[Title Code])<>[Forms]![FormName]![txtTitleCode]) 
  3. AND (([August Employee Roster].Leave)<>[September Employee Roster]![Leave]) 
  4. AND (([September Employee Roster].Leave)="A") 
  5. AND (([September Employee Roster].BL) Not Like "6***") 
  6. AND (([September Employee Roster].Paycode) Not Like "******2" 
  7. And ([September Employee Roster].Paycode) Not Like "******4" 
  8. And ([September Employee Roster].Paycode) Not Like "******6") 
  9. AND (([September Employee Roster].[Emhist Date]) Like "200609**") AND (([September Employee Roster].SeqNum)=1)) 
  10. OR ((([September Employee Roster].Leave)="U"))
  11. ORDER BY [September Employee Roster].[Last Name], [September Employee Roster].Leave;
  12.  
  13.  
Oct 31 '06 #13
You have perfectly understood the point. I will try this out and leave feedback about it. Thank you very much.

Lets just look at the where statement as I assume this is where you want the user criteria to be used.

If for instance you set up a text box on the form called txtTitleCode for the user to enter the Title Code.

you could change this part of the statement to:

Expand|Select|Wrap|Line Numbers
  1.  
  2. WHERE ((([September Employee Roster].[Title Code])<>[Forms]![FormName]![txtTitleCode]) 
  3. AND (([August Employee Roster].Leave)<>[September Employee Roster]![Leave]) 
  4. AND (([September Employee Roster].Leave)="A") 
  5. AND (([September Employee Roster].BL) Not Like "6***") 
  6. AND (([September Employee Roster].Paycode) Not Like "******2" 
  7. And ([September Employee Roster].Paycode) Not Like "******4" 
  8. And ([September Employee Roster].Paycode) Not Like "******6") 
  9. AND (([September Employee Roster].[Emhist Date]) Like "200609**") AND (([September Employee Roster].SeqNum)=1)) 
  10. OR ((([September Employee Roster].Leave)="U"))
  11. ORDER BY [September Employee Roster].[Last Name], [September Employee Roster].Leave;
  12.  
  13.  
Oct 31 '06 #14
By the way, if I want the field to be a wildcard entered from the text box, how would I do that?
Oct 31 '06 #15
Another thing: How can I tie the Command button to run the query based on what I inputted in the text box?

By the way, if I want the field to be a wildcard entered from the text box, how would I do that?
Oct 31 '06 #16
MMcCarthy
14,534 Expert Mod 8TB
By the way, if I want the field to be a wildcard entered from the text box, how would I do that?
Using this line as an example and creating a textbox on the form called txtBL.

AND (([September Employee Roster].BL) Not Like '[Forms]![FormName]![txtBL]*')


BTW you only ever need to use one *.
Oct 31 '06 #17
MMcCarthy
14,534 Expert Mod 8TB
Another thing: How can I tie the Command button to run the query based on what I inputted in the text box?
Just use the wizard to set up a command button to open this query.
Oct 31 '06 #18
I am getting an odd message.

It reads: The text file specification "FISA Link Specification" does not exist. You can import export or link using the specification.

Sounds terrible

Another thing: How can I tie the Command button to run the query based on what I inputted in the text box?
Oct 31 '06 #19
MMcCarthy
14,534 Expert Mod 8TB
I am getting an odd message.

It reads: The text file specification "FISA Link Specification" does not exist. You can import export or link using the specification.

Sounds terrible
You didn't save the specification using the advanced button on the import/export as explained in previous post.
Oct 31 '06 #20
Everything works perfectly... Thank you so much and I am terribly sorry to be a pain in the behind.

Everything worked except for some reason if I do not enter any value (I do not want that value to be entered, the query turns out blank. Its Okay, thats tomorrows concern. Thank you very much.... I really appreciate what you guys do. I never knew that a forum can be so helpful and fun. Thank you - everybody and i'll see you guys tomorrow. :-)


You didn't save the specification using the advanced button on the import/export as explained in previous post.
Oct 31 '06 #21
NeoPa
32,556 Expert Mod 16PB
BTW you only ever need to use one *.
Are you saying that "BlahBlah*" is equivalent to "*BlahBlah*" - or just that "BlahBlah*" is equivalent to "BlahBlah**"?
Oct 31 '06 #22
MMcCarthy
14,534 Expert Mod 8TB
Are you saying that "BlahBlah*" is equivalent to "*BlahBlah*" - or just that "BlahBlah*" is equivalent to "BlahBlah**"?
Adrian

You're such a smart Alec, but you're right.

What I was trying to say was:

"A*" will give everything beginning with A
"*A" will give everything ending in A
"*A*" will give everything with A anywhere

What I was trying to say when I said you only need one * was
that one * will represent any number of characters you don't need a separate * per character.

Mary
Oct 31 '06 #23
MMcCarthy
14,534 Expert Mod 8TB
Everything works perfectly... Thank you so much and I am terribly sorry to be a pain in the behind.
Never think that, its what we're here for.


Everything worked except for some reason if I do not enter any value (I do not want that value to be entered, the query turns out blank. Its Okay, thats tomorrows concern. Thank you very much....
we can help with that come back when you're ready


I really appreciate what you guys do. I never knew that a forum can be so helpful and fun. Thank you - everybody and i'll see you guys tomorrow. :-)
I'm glad to hear that was your experience. Creating a fun atmosphere keeps the experts interested as well which gets your questions answered.
Oct 31 '06 #24
NeoPa
32,556 Expert Mod 16PB
Mary,

Although I like to have a laugh now and again, in this case I had guessed you meant exactly what you said.
I was just trying to clarify in case :-
1. Anyone else misunderstood
2. I found out that actually I was wrong in thinking what I thought.

I'm very pleased to say that I do regularly find out things I either didn't know or had not understood correctly while reading through these forums.

In this case I plead innocent truthfully - your honour.

-Adrian.
Oct 31 '06 #25
MMcCarthy
14,534 Expert Mod 8TB
Mary,

Although I like to have a laugh now and again, in this case I had guessed you meant exactly what you said.
I was just trying to clarify in case :-
1. Anyone else misunderstood
2. I found out that actually I was wrong in thinking what I thought.

I'm very pleased to say that I do regularly find out things I either didn't know or had not understood correctly while reading through these forums.

In this case I plead innocent truthfully - your honour.

-Adrian.
Adrian

I was only joking

I responded to this post in a hurry and your point was a good one.

Mary
Oct 31 '06 #26

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

Similar topics

1
by: Cory | last post by:
When I run the subroutine testEmailContacts the msgbox says that there is only 1 record. The sql for qyEmailContactsQyCard is below. There is over 3000 records in the table "tbl:Contact". What am i...
5
by: SuffrinMick | last post by:
Hello - I'm a newbie to coding! I'm working on an access 2000 database which has three tables: tblContacts - A list of customer contacts. tblOrgTypes - A list of organisational types....
8
by: Drum2001 | last post by:
I have a form that contains 8 textboxes "Textbox30, Textbox31, Textbox32, Textbox33, Textbox34, Textbox35, Textbox36, Textbox37". This form is designed to allow the user to input up to eight...
6
by: jim | last post by:
Is anyone able to provide me with a link to useful documentation or just outright explain to me how to set query parameters dynamically? I'm really new to Access and databases in general but I...
2
by: Mark Roughton | last post by:
I have a form where the users need to view records for various criteria, one of which is a date field on which they may wish to view all related data for the selected date, for all dates upto and...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
3
by: emily.a.day | last post by:
I have a book database, and I have set up a query to search by subject. As it is now, the searcher has to know the subject and type it into the query. I wonder if there is a way to have a combo...
8
by: Sid | last post by:
I hope someone could help me with this. I am trying to setup a criteria to decide when to allow/not allow user to click on the check box. logically it looks simple but I am not able to...
4
by: torontolancer | last post by:
Hi there how r u .I would really appriciate ur concern regarding checking out this code. its beind a command button and i am have a combo box selecing a query criteria and then pressing the button...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
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
isladogs
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...

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.