| View previous topic :: View next topic |
| Author |
Message |
caster89 General User

Joined: 29 Nov 2007 Posts: 30
|
Posted: Sat Feb 02, 2008 5:38 am Post subject: Visualize button if data is present |
|
|
Is there a way to have a button appear only if there is data present in a set field?! Let me explain i want a button to be visible only if I have a picture present, if not i wantit to be either invisible or greyed out kind of like when u try to select copy but there is nothing selected.
Thanks guys... |
|
| Back to top |
|
 |
QuazzieEvil Super User

Joined: 17 Jan 2007 Posts: 599 Location: Houston, TX
|
Posted: Sat Feb 02, 2008 9:03 am Post subject: |
|
|
If your picture column an Image/LONGVARBINARY? if that is the case you can bind following code to the after record action event of the form:
| Code: |
Sub IsNullImage(Event As Object)
Dim form As Object
Dim button As Object
Dim Col As Object
Form=Event.Source
button=Form.getByName("cmdCopyToBookMark") REM button to enable/disable
Col=Form.Columns.getByName("PICTURE")
If Col.BinaryStream.Length=0 Then
button.Enabled=False
Else
button.Enabled=True
End If
End Sub
|
If the Picture column is not an Image (the data type) use the appropirate test to see if it has data or not. for example, if all you are storing is the path, check for empty string.
hope this helps. |
|
| Back to top |
|
 |
caster89 General User

Joined: 29 Nov 2007 Posts: 30
|
Posted: Sun Feb 03, 2008 1:03 am Post subject: |
|
|
how do i get to the after record action, i wen on tools-->macro-->organize macro-->OpenOffice.org Basic and then assign to, but there is nothing refferd to the record....
By the way if i go it right: i have to put the name of the button in place of and the name of the field in place of .
Is it possible to do it for more than one button in the same form?
Thanks Quazzie |
|
| Back to top |
|
 |
QuazzieEvil Super User

Joined: 17 Jan 2007 Posts: 599 Location: Houston, TX
|
Posted: Sun Feb 03, 2008 10:43 am Post subject: |
|
|
save the code any where you want in the macros libraries.
the, open your form in edit mode, open the properties dialog for the form. then select the event of choice from the events tab.
you can manipulate any controls you want. in that examle, I disabled a command named 'cmdCopyToBookMark', you can replace that with the name of your button. and the name of the table field, for my example was 'PITURE'. so yes, replace those with your own. |
|
| Back to top |
|
 |
caster89 General User

Joined: 29 Nov 2007 Posts: 30
|
Posted: Tue Feb 05, 2008 2:59 am Post subject: |
|
|
I wrote the code...this is what i did:
| Code: | Sub Visualizza(Event As Object)
Dim form As Object
Dim button As Object
Dim Col As Object
Form=Event.Source
button=Form.getByName("Ingrandisci") REM button to enable/disable
Col=Form.Columns.getByName("Foto")
If Col.BinaryStream.Length=0 Then
button.Enabled=False
Else
button.Enabled=True
End If
End Sub |
and i was also able to find the after action record....i also tried others...but for some reason it won't work, the button is always visible, and it always works?! am i doning something wrong?! it gives me no error message though!!!!
Thanks |
|
| Back to top |
|
 |
QuazzieEvil Super User

Joined: 17 Jan 2007 Posts: 599 Location: Houston, TX
|
Posted: Tue Feb 05, 2008 8:42 am Post subject: |
|
|
| the button is only disabled, so it should be still visible. by it always works, do you mean you can click on the button even if there is no image in the column? |
|
| Back to top |
|
 |
caster89 General User

Joined: 29 Nov 2007 Posts: 30
|
Posted: Tue Feb 05, 2008 10:36 am Post subject: |
|
|
| yeah i mean i use the button to open a new form where the picure is shown bigger, and it still opens the form even if there is no picture...there is no way to hide it right?! |
|
| Back to top |
|
 |
QuazzieEvil Super User

Joined: 17 Jan 2007 Posts: 599 Location: Houston, TX
|
Posted: Tue Feb 05, 2008 12:26 pm Post subject: |
|
|
Hmmm...I think that is my fault. I believe I told you to use the 'After Record Action' You need to be using the 'After Record Change'..sorry, that is just a bit embarassing.
the Record change event fires whenever you move from one record to another. the '*Record Action' events fire when you insert, delete, or update a record.
I think this might be your problem. The 'After Record Change' event is just be low the record action events.
hope this helps. |
|
| Back to top |
|
 |
caster89 General User

Joined: 29 Nov 2007 Posts: 30
|
Posted: Fri Feb 08, 2008 2:27 pm Post subject: |
|
|
Thanks that worked...i thought i had tried them all but i guess i had forgotten that one!!!!! sry for that.....it works perfect, but i was wondering if it's possible to hide it or grey it out....I looked around for a commend like or something like that but i guess it doesn't exist, does it......
Thanks again for all your help don't know where i'd be right now!!!! |
|
| Back to top |
|
 |
QuazzieEvil Super User

Joined: 17 Jan 2007 Posts: 599 Location: Houston, TX
|
Posted: Fri Feb 08, 2008 7:49 pm Post subject: |
|
|
| I have tried to hide (and delete for that matter) a control, but without success. either I have not found the necessary steps, or it is not possible. |
|
| Back to top |
|
 |
|