There is a form with some fields and a button which goes to the next records. how can we make the button inactive otherwise all or some of the filed are filed?
Thank you
There is a form with some fields and a button which goes to the next records. how can we make the button inactive otherwise all or some of the filed are filed?
Thank you
I'd create a form level function and call if from the after update event of the relevant controls. That function would test them all, and enable/disable the button as appropriate.
thank you, but how can i make that? i mean imagine there are three blank spaces tobe filed, named: blank1, blank2, blank3. and the button is supposed to go to thext record. but i want it to be active only if all the blanks are filed with appropriate data.
how should i write the function? is that a VB? where should i put the code?
thank you
You could add code in the button OnClick event which checks all the fields and does not go to the next record unless all the fields have values.
Yes, VBA code. Code for a particular event goes here:thank you, but how can i make that? i mean imagine there are three blank spaces tobe filed, named: blank1, blank2, blank3. and the button is supposed to go to thext record. but i want it to be active only if all the blanks are filed with appropriate data.
how should i write the function? is that a VB? where should i put the code?
thank you
http://www.baldyweb.com/FirstVBA.htm
A form level function would go at the top of the form's code:
http://www.baldyweb.com/Function.htm
The code itself might look like:
Code:If Len(Me.FirstControl & vbNullString) > 0 AND Len(Me.SecondControl & vbNullString) > 0 Then Me.ButtonName.Enabled = True Else Me.ButtonName.Enabled = False End If
Thank you,
i tried this code in the VBA code part:
it is obiouse that 10 is greater then zero. So the button was enabled. Then i inserted “10 <0” , and the button was disabled since 10 is obviously more than 0.Code:Private Sub Form_Current() If 10 > 0 Then Me.moresale.Enabled = True Else Me.moresale.Enabled = False End If End Sub
But when it did not work when i made the actual condition as the following:
Now the button was always disabled, either the control name (phone) is blank or is filed correctly.Code:Private Sub Form_Current() If Len(Me.phone) > 0 Then Me.moresale.Enabled = True Else Me.moresale.Enabled = False End If End Sub
i dont know what goes wrong when put a condition instead of an obviouse statement.
thank you
Can you attach the db here?
thank you for helping me out. here is the DB. i upladed to my site hosting.
Last edited by ariansman; 01-26-2017 at 12:17 PM.
I don't download from unknown sites, but perhaps somebody else can.
it is understandable, but i couldnt find a way to attach it here. thank you BTW
there is no need to download my DB sicne it is very easy to make it. i made a new DB, with two forms. form1 and form2. form1 has a blank named "phone" and a buttom named "moresale". the button is supposed to open form2 if activated. then i put the above VBA in the code of form one. you will see that it is not working. any help is appreciated.
You can attach a db in the "Go Advanced" area. If it's larger, zip first.
good, thank you , i attached it here. in the zip form
test2017.zip
As I said originally, the code needs to run from the after update event of the number textbox. The current event only fires when changing records or on load, which is irrelevant with an unbound form. More here:
http://www.baldyweb.com/ConditionalVisibility.htm