OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Visualize button if data is present

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
caster89
General User
General User


Joined: 29 Nov 2007
Posts: 30

PostPosted: Sat Feb 02, 2008 5:38 am    Post subject: Visualize button if data is present Reply with quote

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
View user's profile Send private message
QuazzieEvil
Super User
Super User


Joined: 17 Jan 2007
Posts: 599
Location: Houston, TX

PostPosted: Sat Feb 02, 2008 9:03 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caster89
General User
General User


Joined: 29 Nov 2007
Posts: 30

PostPosted: Sun Feb 03, 2008 1:03 am    Post subject: Reply with quote

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
Code:
cmdCopyToBookMark
and the name of the field in place of
Code:
Picture
.
Is it possible to do it for more than one button in the same form?
Thanks Quazzie
Back to top
View user's profile Send private message
QuazzieEvil
Super User
Super User


Joined: 17 Jan 2007
Posts: 599
Location: Houston, TX

PostPosted: Sun Feb 03, 2008 10:43 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caster89
General User
General User


Joined: 29 Nov 2007
Posts: 30

PostPosted: Tue Feb 05, 2008 2:59 am    Post subject: Reply with quote

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!!!! Confused
Thanks
Back to top
View user's profile Send private message
QuazzieEvil
Super User
Super User


Joined: 17 Jan 2007
Posts: 599
Location: Houston, TX

PostPosted: Tue Feb 05, 2008 8:42 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caster89
General User
General User


Joined: 29 Nov 2007
Posts: 30

PostPosted: Tue Feb 05, 2008 10:36 am    Post subject: Reply with quote

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
View user's profile Send private message
QuazzieEvil
Super User
Super User


Joined: 17 Jan 2007
Posts: 599
Location: Houston, TX

PostPosted: Tue Feb 05, 2008 12:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caster89
General User
General User


Joined: 29 Nov 2007
Posts: 30

PostPosted: Fri Feb 08, 2008 2:27 pm    Post subject: Reply with quote

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
Code:
setVisualize(TRUE)
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
View user's profile Send private message
QuazzieEvil
Super User
Super User


Joined: 17 Jan 2007
Posts: 599
Location: Houston, TX

PostPosted: Fri Feb 08, 2008 7:49 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group