How to hide button

solty89

Registered User.
Local time
Today, 02:32
Joined
May 20, 2013
Messages
32
Hi guys,
i would like to hide/show button depend on is there anything in a fielld.My current code is not working at the moment so pls help me where is the mistake:

Private Sub Form_Load()
If Form![fourniturenErrorsub]![Code Field] <> Null Then
errorbtn.Visible = True
Else
errorbtn.Visible = False

End If
 
solty89, Try this..
Code:
Private Sub Form_Load()
    Me.errorbtn.Visible = CBool(Len(Me.[Code Field] & vbNullString) <> 0)
End Sub
 
What exactly do you mean by not working? Is this form a Continuous Form? Is there any other conflicting code maybe in Form Current? Have you tried debugging by setting breakpoints?
 
What exactly do you mean by not working? Is this form a Continuous Form? Is there any other conflicting code maybe in Form Current? Have you tried debugging by setting breakpoints?

the debuging its saying that it cant find the field.so there is the mistake in the code.its a subform in the form called "fourniturenerrorsub" and the field is in the subform called "code field".
 
Refer to THIS LINK on how to properly access the SubForm controls.. Then use the Code I gave you..
 
wtf ive tryed everything :(((
Calm down ! :rolleyes:

Upload a stripped DB..

How to Upload a Stripped DB.

To create a Sample DB (to be uploaded for other users to examine); please follow the steps..

1. Create a backup of the file, before you proceed..
2. Delete all Forms/Queries/Reports that are not in Question (except the ones that are inter-related)
3. Delete auxiliary tables (that are hanging loose with no relationships).
4. If your table has 100,000 records, delete 99,990 records.
5. Replace the sensitive information like Telephone numbers/email with simple UPDATE queries.
6. Perform a 'Compact & Repair' it would have brought the Size down to measly KBs..
7. (If your Post count is less than 10 ZIP the file and) Upload it..

Finally, please include instructions of which Form/Query/Code we need to look at. The preferred Access version would be A2003-A2007 (.mdb files)
 
Upload a stripped DB..

How to Upload a Stripped DB.

To create a Sample DB (to be uploaded for other users to examine); please follow the steps..

1. Create a backup of the file, before you proceed..
2. Delete all Forms/Queries/Reports that are not in Question (except the ones that are inter-related)
3. Delete auxiliary tables (that are hanging loose with no relationships).
4. If your table has 100,000 records, delete 99,990 records.
5. Replace the sensitive information like Telephone numbers/email with simple UPDATE queries.
6. Perform a 'Compact & Repair' it would have brought the Size down to measly KBs..
7. (If your Post count is less than 10 ZIP the file and) Upload it..

Finally, please include instructions of which Form/Query/Code we need to look at. The preferred Access version would be A2003-A2007 (.mdb files)[/QUOTE]

View attachment Lundia Database v1.0n.zip
the form is "fourniturenform" and the button is called "duplicate record"
 
See if I am following you.. All you want is, check if there are any records in the Sunform.. If there is any you need the button to be visible, if not it should be invisible? If that is what you are looking for, then this will suffice..
Code:
Me.errorbtn.Visible = Not CBool(DCount("*", "fourniturenErrors") = 0)
If that is not you were looking for, explain what exactly are you after !

On a totally different topic.. I don't think your tables are all Normalized.. There are so many Queries, does you application need so many Queries?

Also there is a reason I call it Stripped DB.. Please note the next time you post your DB, delete some objects !
 
See if I am following you.. All you want is, check if there are any records in the Sunform.. If there is any you need the button to be visible, if not it should be invisible? If that is what you are looking for, then this will suffice..
Code:
Me.errorbtn.Visible = Not CBool(DCount("*", "fourniturenErrors") = 0)
If that is not you were looking for, explain what exactly are you after !

On a totally different topic.. I don't think your tables are all Normalized.. There are so many Queries, does you application need so many Queries?

Also there is a reason I call it Stripped DB.. Please note the next time you post your DB, delete some objects !

Yes, this is exactly what i want ,but this code is giving me error.
So im sure there must be easiest way for the most of the things in the application ,but this is how i did it so far with my knowledge.no it education, no idea of programing
 
What error does it give? I used the exact code in the Form On Load event, just before the call clearFilter line of code.. It worked fine.. Sorry I deleted the file from my system..
 
What error does it give? I used the exact code in the Form On Load event, just before the call clearFilter line of code.. It worked fine.. Sorry I deleted the file from my system..

Yes brav, my mistake.It works.Thank you.you are legend
 

Users who are viewing this thread

Back
Top Bottom