Query help (don't run if false)

keith701a

Registered User.
Local time
Today, 13:49
Joined
Aug 9, 2016
Messages
38
An update form opens with the attached query. The form opens with empty fields if report_number has a "true" research_request. I want this to happen, but I'm worried this will confuse users.

Is there a way to stop the query from running if research_request is true?
 

Attachments

  • Capture.PNG
    Capture.PNG
    7.9 KB · Views: 100
Last edited:
I think the easiest way would be to have code on the button to run the query that says:

Code:
if research_request = true then
Exit sub
End if
that way the query will not run if the condition above is met.
 
I think the easiest way would be to have code on the button to run the query that says:

Code:
if research_request = true then
Exit sub
End if
that way the query will not run if the condition above is met.

What I failed to mention is the button is a navigation button on the main form. The update form opens as a subform after the report number is keyed.
 
I guess I do not understand what you mean. If the query then opens up a subform somewhere, then maybe just a Message box message saying that there are no records where the research request = True along with the code I posted.

Perhaps if you posted some more data, or a stripped down version of what you are trying to do, someone with more expertise than I could figure out a solution.
 
You would have to attach some code that checked the query results. Something like
Code:
If DCount("*","YourQuery") < 1 Then     'There are no records so don't  open your form
   msgbox "No records to update"
   Exit Sub
End If
' Put you open form code here
 
You would have to attach some code that checked the query results. Something like
Code:
If DCount("*","YourQuery") < 1 Then     'There are no records so don't  open your form
   msgbox "No records to update"
   Exit Sub
End If
' Put you open form code here
Put this in the "on open" event?
 
No on the on click of the button that opens the form.
 
No on the on click of the button that opens the form.

The button that opens the form is a navigation button. Can I add it to the "on click" event to a navigation button?
 
Ah - pesky in-built navigation forms...
I don't use them at all, so can't say if you can get around that issue I'm afraid.
 
Ah - pesky in-built navigation forms...
I don't use them at all, so can't say if you can get around that issue I'm afraid.

I'm realizing how annoying they really are. It was a pain in the ass to get simple things to work, like save buttons and and certain queries.

I entered that code in the "on click" event, and it returns an error on the report number.
 
I would build you own form with Command buttons on it to do the simple stuff to start with. You are then in complete control.
I really dislike the way the in built navigation forms embed everything within the main navigation form.
 
I would build you own form with Command buttons on it to do the simple stuff to start with. You are then in complete control.
I really dislike the way the in built navigation forms embed everything within the main navigation form.

I originally built it as a sort of launch pad (form with a bunch of buttons), but the amount of windows confused everyone. I've designed it with the lowest common denominator in mind, which is pretty low.
 
You might benefit from the use of forms with tabbed pages. These can reduce the use of multiple forms with different parts of the data on. Put each part of the data that needs to be grouped together on the relevant tab, then your users aren't jumping around loads of different forms.

I re-did one recently and went from 8 separate forms to 1 with the data organised on tabs. It took a little effort but is a much nicer and simpler user experience.
 
You might benefit from the use of forms with tabbed pages. These can reduce the use of multiple forms with different parts of the data on. Put each part of the data that needs to be grouped together on the relevant tab, then your users aren't jumping around loads of different forms.

I re-did one recently and went from 8 separate forms to 1 with the data organised on tabs. It took a little effort but is a much nicer and simpler user experience.

I get what you're saying with the tabs, I have that setup for several entry forms. I still can't get this to work. I figured a fair solution would be to just have a custom dialog form open if the condition is met. I'm not great a VBA, so attempted an OpenForm macro on the "on open" event. I used this as the where condition: [NavigationSubform].Form![RRUPD] = FALSE

The error form open regardless if the field is false or true (I even gave the field a custom name so it could be referenced). What am I doing wrong?
 
If you convert the macro to VBA and post up the code it gives you we can probably spot the flaw , with Macro's I've no idea how to go about fixing it tbh.
 

Users who are viewing this thread

Back
Top Bottom