Why my click event doesn't work?

Status
Not open for further replies.

sarkis

Registered User.
Local time
Today, 11:45
Joined
Mar 15, 2012
Messages
10
Hi again
I have still a problem.
I have a simple form with a text box and a button.
The control source for a text box is a numeric field id1.
I am trying to increase the value of tables field by clicking button.
Here is a click event.

Private Sub mCommand1_Click()
Me.id1 = Me.id1 + 1
End Sub

But this doesn't work
Thanks for answers.
 
what error do you get?

are you sure your button is firing?

is the field an autonumber?
 
I didn't get any error.
It seems me that click event doesn't run.
 
First up all that code will do is increment the value of id1 by one for the current record. It will not work if the current value is Null.

If all you wan to do is increment the value of id1 by each time the user click the button use;
Code:
Me.id1 = [URL="http://www.techonthenet.com/access/functions/advanced/nz.php"]Nz[/URL](Me.id1 + 1, 1)

If what you are actually trying to do is to implement your own Auto Number function the following Code in the Form's On Current event Should do the trick;

Code:
    If Me.id1= 0 Or IsNull(Me.id1) Then
        Me.id1= Nz(DMax("id1", "YourTableName"), [B][COLOR="Red"]X[/COLOR][/B]) + 1
    End If

Note; Replace X with your seed number (the number you wish your series to start at).
 
Thank you for respond.
Problem was not on in the Null value
I understand what was a problem.
Actually records are changing ,but it doesn't appear in the form.
The form is need to be "refreshed" or make some change the record position on the table.
(I don't know how to do that)
Anyway thanks again
 
Status
Not open for further replies.

Users who are viewing this thread

Back
Top Bottom