|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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:
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
how about doing
Code:
if(DoCmd.OpenQuery "queryname") then ... else ... endif |
|
#5
|
|||
|
|||
|
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? |
|
#6
|
||||
|
||||
|
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
![]() |
|
#7
|
|||
|
|||
|
ok, ill give it a go, thanks a lot for your help!
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > VBA in Access 2000 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|