Next task (1 Viewer)

ChrisC

Registered User.
Local time
Today, 14:17
Joined
Aug 13, 2019
Messages
90
Ok, so I have now got a working image database that works a charm. I have successfully added various check boxes and search (filter) criteria using what I learnt so far from help on this forum so I'm very happy!

My next task is to have a button appear if a check box on a row is checked; there are multiple rows on my form and I only want the button to appear on lines where that tick box is checked.

Ultimately, the button in question will be clicked for users to open a .PDF file; the path of which is stored in the table for this form.

I have been using the following syntax but can only make the button appear on ALL lines or none of them.


If Me.Check60 = -1 Then
Me.Command62.Visible = True
Else
Me.Command62.Visible = False
End If


Excuse the naming, but Check60 is the tickbox in question, and Command62 is the button I want to appear.

The tick box is automatically checked based on information in the table; nothing is "updated" as such when the form is being viewed.

I have read on some websites that this simply isn't possible - buttons can only be shown "all or nothing"... is that true? I cant find an alternative solution without having the full path of the PDF file shown - which to me just looks untidy (hence why I want to swap it to a simple button).

Thanks as always,
Chris
 

isladogs

MVP / VIP
Local time
Today, 14:17
Joined
Jan 14, 2017
Messages
18,186
If you are using a continuous form, there is actually only one set of controls but displayed multiple times. This means the buttons are indeed all or nothing.

However you could use conditional formatting to disable a textbox control where your checkbox is false...but CF isn't available for buttons

BTW I woulds use meaningful names rather than Check60, Command62 etc
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:17
Joined
May 7, 2009
Messages
19,175
if it is a continuous form that you have, you can't.
try replacing the command button with unbound textbox or label and use conditional format to change its font's forecolor.
 

ChrisC

Registered User.
Local time
Today, 14:17
Joined
Aug 13, 2019
Messages
90
Hi Colin,

Thanks, at least that stops me going round in circles for hours ha ha.

Conditional Formatting is greyed out for buttons, so I'm presuming that simply some controls can not have formatting applied?

thanks

PS - names changed now :)
 

ChrisC

Registered User.
Local time
Today, 14:17
Joined
Aug 13, 2019
Messages
90
if it is a continuous form that you have, you can't.
try replacing the command button with unbound textbox or label and use conditional format to change its font's forecolor.

Hi Arnelgp,

I will give that a try - thank you :)

I guess that would get around not being able to apply formatting to a button... make something else look like a button instead.

thank you
 

isladogs

MVP / VIP
Local time
Today, 14:17
Joined
Jan 14, 2017
Messages
18,186
Hi Chris
Conditional formatting is used for textboxes and comboboxes.
AFAIK it doesn't work for any other types of controls.

People often use labels in place of buttons but that won't help in your case as you can't apply CF to a label as stated above
 

ChrisC

Registered User.
Local time
Today, 14:17
Joined
Aug 13, 2019
Messages
90
thank you all - I have got the text box to be active/not-active based on the tick box value; but is there a way to make the greyed out, non active text boxes completely invisible?
 

isladogs

MVP / VIP
Local time
Today, 14:17
Joined
Jan 14, 2017
Messages
18,186
You can’t hide objects using CF. However you could make the text box fore colour and back colour the same as your form colour

If so you won’t need to disable them as well
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 10:17
Joined
Feb 19, 2002
Messages
42,983
The checkbox sounds redundant. Are you setting the checkbox to true for those items that have PDF's?

I would create a query with a calculated column:

Select ...., IIf(IsNull(PDFpathname, null, "Open") as HasPdf From yourtable

Bind a text box to the HasPDF field. All the values will be spaces or Open. set the format to display as HyperLink so the "Open" looks clickable. You will need code in the click event to ensure that there is a PDF address prior to using the FollowHyperLInk method just to avoid an error if someone clicks on the "empty" box.

PS - rather than apologizing for the poor control name, try to get into the habit of making sure controls are named correctly when you create them. If you drag a field from the available fields list, Access will give your control the name of the bound field. However, when you pick controls from the ribbon, Access doesn't know whether they will ever be bound or what column they will be bound to so it just names them text123. As soon as you add the control, do not pass go, do not collect $200, immediately rename the control so you don't have to come back to it later:cool:
 

ChrisC

Registered User.
Local time
Today, 14:17
Joined
Aug 13, 2019
Messages
90
Hi Pat,

You're correct about the checkbox; it is simply to show whether "that" line has a PDF - but now you highlight it, I guess it is redundant. The checkbox is never updated from within the form - it is simply there as an instant visual aid to whether there is a file or not.

Forgive my ignorance - in a Query, how do I enter a calculated field? That is to say - where do I enter the calculation? Using the wizard I have a query that now shows 2 columns: the PrimaryKey, and one showing the PDF path if there is one, or simply blank if there isn't.

I must admit, "normally" in everything else I do, I do rename things to something meaningful from the start. This time I just didn't do it for some reason (probably because im rushing between this and doing my job!). Thank you though for the heads up - you are of course correct; naming things straight away is the best policy every time :)


Thanks
Chris
 

ChrisC

Registered User.
Local time
Today, 14:17
Joined
Aug 13, 2019
Messages
90
Well I would say that I have achieved (sort of) what I want - certainly good enough to be able to move on with the project!

So thanks once again to all for the help!

Watch this space for the next cry for help... working out how to do a query to show for a given partID (entered in a text field) all the WHLocat (warehouse locations) that are associated with the Part and the qty in each of those locations (quantity and locations stored in a new table).

I think that will be for a different thread though (after I have had a go myself of course :))

thanks everyone
Chris
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 10:17
Joined
Feb 19, 2002
Messages
42,983
In my post, I showed how to create a calculated field in a query. You can do it in QBE view but that' too hard to see here so switch to SQL View, find the end of the select clause, add a comma, then the new field. The dots in the example are what already exists of your query. You will also have to change PDFPathName to whatever you called that column.
 

Users who are viewing this thread

Top Bottom