Enabling a button based on a query

  • Thread starter Thread starter Fatz
  • Start date Start date
F

Fatz

Hi...is there a way to enable a button based on the results of a
query? I have a button on a form that when clicked opens a seperate
modal form that is connected to the ID field of a query. So this form
will only show records for that specific ID. (So I open the first
form for ID 6. From this form I have a "History" button that opens
the modal that has only the history for ID 6...)

Right now I have some code behind the On Open command that makes some
fields visible based on results in the query.

If Me![Shares Returned 1] < 1 Then
Me![Shares Returned 1].Visible = False
Else
Me![Shares Returned 1].Visible = True
End If

My problem is this: Sometimes the IDs have no history (and the users
will have no way of knowing whether an ID has history or not) so there
is no record of that particular ID in my query. Since there is no
record I get an error message ("You've entered an expression that has
no value.").

Is there a way to only have this "History" button enabled if the query
contains the specific ID that is open on the main form???

Thanks in advance to all!

-Chris
 
You can use a DLookup() to determine if there are any history records for
that ID, and set the button's Visible property accordingly.

HTH
- Turtle
 
Turtle-

Thanks for giving me a solid approach to solving this. Trouble is I
don't know how to go about doing this. Can you let me know how to
implement the DLookup command??

Thanks,
Chris

MacDermott said:
You can use a DLookup() to determine if there are any history records for
that ID, and set the button's Visible property accordingly.

HTH
- Turtle

Fatz said:
Hi...is there a way to enable a button based on the results of a
query? I have a button on a form that when clicked opens a seperate
modal form that is connected to the ID field of a query. So this form
will only show records for that specific ID. (So I open the first
form for ID 6. From this form I have a "History" button that opens
the modal that has only the history for ID 6...)

Right now I have some code behind the On Open command that makes some
fields visible based on results in the query.

If Me![Shares Returned 1] < 1 Then
Me![Shares Returned 1].Visible = False
Else
Me![Shares Returned 1].Visible = True
End If

My problem is this: Sometimes the IDs have no history (and the users
will have no way of knowing whether an ID has history or not) so there
is no record of that particular ID in my query. Since there is no
record I get an error message ("You've entered an expression that has
no value.").

Is there a way to only have this "History" button enabled if the query
contains the specific ID that is open on the main form???

Thanks in advance to all!

-Chris
 
Try the Access Help file for starters.

HTH
- Turtle

Fatz said:
Turtle-

Thanks for giving me a solid approach to solving this. Trouble is I
don't know how to go about doing this. Can you let me know how to
implement the DLookup command??

Thanks,
Chris

"MacDermott" <[email protected]> wrote in message
You can use a DLookup() to determine if there are any history records for
that ID, and set the button's Visible property accordingly.

HTH
- Turtle

Fatz said:
Hi...is there a way to enable a button based on the results of a
query? I have a button on a form that when clicked opens a seperate
modal form that is connected to the ID field of a query. So this form
will only show records for that specific ID. (So I open the first
form for ID 6. From this form I have a "History" button that opens
the modal that has only the history for ID 6...)

Right now I have some code behind the On Open command that makes some
fields visible based on results in the query.

If Me![Shares Returned 1] < 1 Then
Me![Shares Returned 1].Visible = False
Else
Me![Shares Returned 1].Visible = True
End If

My problem is this: Sometimes the IDs have no history (and the users
will have no way of knowing whether an ID has history or not) so there
is no record of that particular ID in my query. Since there is no
record I get an error message ("You've entered an expression that has
no value.").

Is there a way to only have this "History" button enabled if the query
contains the specific ID that is open on the main form???

Thanks in advance to all!

-Chris
 
The help files did nothing for me. I am a newbie....please help!!!!!

-Chris


MacDermott said:
Try the Access Help file for starters.

HTH
- Turtle

Fatz said:
Turtle-

Thanks for giving me a solid approach to solving this. Trouble is I
don't know how to go about doing this. Can you let me know how to
implement the DLookup command??

Thanks,
Chris

"MacDermott" <[email protected]> wrote in message
You can use a DLookup() to determine if there are any history records for
that ID, and set the button's Visible property accordingly.

HTH
- Turtle

Hi...is there a way to enable a button based on the results of a
query? I have a button on a form that when clicked opens a seperate
modal form that is connected to the ID field of a query. So this form
will only show records for that specific ID. (So I open the first
form for ID 6. From this form I have a "History" button that opens
the modal that has only the history for ID 6...)

Right now I have some code behind the On Open command that makes some
fields visible based on results in the query.

If Me![Shares Returned 1] < 1 Then
Me![Shares Returned 1].Visible = False
Else
Me![Shares Returned 1].Visible = True
End If

My problem is this: Sometimes the IDs have no history (and the users
will have no way of knowing whether an ID has history or not) so there
is no record of that particular ID in my query. Since there is no
record I get an error message ("You've entered an expression that has
no value.").

Is there a way to only have this "History" button enabled if the query
contains the specific ID that is open on the main form???

Thanks in advance to all!

-Chris
 
Back
Top