Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 11th, 2004, 03:58 PM
cjr_chris cjr_chris is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 7 cjr_chris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
VBA in Access 2000

I'm trying to get a query to run from a form to check whether the textbox's data exists anywhere in a column of a table. I h i have managed to run a query by using the on exit property of the control on the text box, then the code DoCmd.OpenQuery "queryname"
but the query that i run produces its results on screen, which is not what i want to happen. i want the query to just say yes there are results, or no there are no results. and then run the next bit of VBA code accordingly.

Any ideas would be much appreciated!

Thanks
Chris

Reply With Quote
  #2  
Old February 12th, 2004, 11:05 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
Chris:

Post what code you have and we'll be more than happy to help you with this. I've done things in VBA and access for a while now.. what program in vba is this for? an excel form? word? what?

Thanks

Quote:
Originally Posted by cjr_chris
I'm trying to get a query to run from a form to check whether the textbox's data exists anywhere in a column of a table. I h i have managed to run a query by using the on exit property of the control on the text box, then the code DoCmd.OpenQuery "queryname"
but the query that i run produces its results on screen, which is not what i want to happen. i want the query to just say yes there are results, or no there are no results. and then run the next bit of VBA code accordingly.

Any ideas would be much appreciated!

Thanks
Chris

Reply With Quote
  #3  
Old February 12th, 2004, 11:22 AM
cjr_chris cjr_chris is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 7 cjr_chris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
current code

It's for a form in Microsoft Access 2000. Only bit of VBA im using at the moment is

DoCmd.OpenQuery "queryname"

then it runs the relevant query which just searches down a column on a table using the information in a text box on a form as its criteria. I want the result of the query to come back as yes/no. rather than listing which ones exist. Then once it has an answer yes/no, if the answer is yes to switch the focus to the next textbox on the userform, if the answer is no then call another userform to add that data.

To run that line of VBA i have used the On Exit property of the textbox on the userform.

Thanks!
Chris

Reply With Quote
  #4  
Old February 12th, 2004, 11:29 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
how about doing
Code:
if(DoCmd.OpenQuery "queryname") then
...
else
...
endif

Reply With Quote
  #5  
Old February 12th, 2004, 11:33 AM
cjr_chris cjr_chris is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 7 cjr_chris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
but if you do that, dont u need it to be like

if(DoCmd.OpenQuery "queryname") = true then
...
else
...
end if

otherwise you still dont get a yes/no?

Reply With Quote
  #6  
Old February 12th, 2004, 11:50 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
It's been a little while since I've coded in vba but I believe that if you just use the if(doCmd.OpenQuery "queryname") then it will either be true or false, so if you don't make a specification, then the if statement will look to see if it's true only, and if it is then it will execute the code within, otherwise it skips it

Reply With Quote
  #7  
Old February 12th, 2004, 11:57 AM
cjr_chris cjr_chris is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 7 cjr_chris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ok, ill give it a go, thanks a lot for your help!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > VBA in Access 2000


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek