Autonumber not executing any of my code to check a checkbox

bmaccess

Member
Local time
Yesterday, 22:51
Joined
Mar 4, 2016
Messages
78
Hi. I need help with the following please.

When I type in a number in the StudentBookIssue_ID the code runs perfectly and the checkbox get checked.
When I set the field to an autonumber the number gets inserted but the code does not get execute. And my
IssuedLearner.Value stay false.


Private Sub StudentBookIssue_ID_AfterUpdate()
If (StudentBookIssue_ID.Value = True) And (IssuedLearner.Value = False) Then
IssuedLearner.Value = True
End If

Thanks
 
Can you post a sample copy of your db with test data?
 
But an autonumber doesn't require user interaction on a form. So how is the after update going to fire? The autonumber is created at the table level, not the form level. You are probably on another field when the ID populates, right?

Much better to use the FORMS Before Update for something like this.
 
I am still busy with my book control application. When a book is issued an autonumber will be assigned and a checkbox must be activated to indicate that a book was issued and the store count must update by subtracting 1 from the total. Not sure if you understand my scenario.
 
So if new record set that checkbox?
However you should be calculating available books, not storing available book numbers.
 
I am on this form. When I add the book Top Class Life Skills 1 i must get a autonumber in Student BookIssue_ID and the checkbox must be ticked.
as the book above it. Current I have typed 1,2,3,4,5,6,7 and the issued checkbox was ticked and total_in_store was was update.
I need to achieve exactly the same if an autonumber was added in Student BookIssue_ID. Is it possible to achieve same effect with an autonumber?
1695587424377.png
 
So if new record set that checkbox?
However you should be calculating available books, not storing available book numbers.
The total of books are calculate. The total_in_store is being deducted by 1 if a book is issued and added by 1 if a book is returned
 
The total of books are calculate. The total_in_store is being deducted by 1 if a book is issued and added by 1 if a book is returned
That is not calculated, that is storing the result? :(
Never advised to do thar.
 
I am on this form. When I add the book Top Class Life Skills 1 i must get a autonumber in Student BookIssue_ID and the checkbox must be ticked.
as the book above it. Current I have typed 1,2,3,4,5,6,7 and the issued checkbox was ticked and total_in_store was was update.
I need to achieve exactly the same if an autonumber was added in Student BookIssue_ID. Is it possible to achieve same effect with an autonumber?
View attachment 110013
As per post #2, post your db.
 
I am on this form. When I add the book Top Class Life Skills 1 i must get a autonumber in Student BookIssue_ID and the checkbox must be ticked.
as the book above it. Current I have typed 1,2,3,4,5,6,7 and the issued checkbox was ticked and total_in_store was was update.
I need to achieve exactly the same if an autonumber was added in Student BookIssue_ID. Is it possible to achieve same effect with an autonumber?
Autonumbers do not execute code, events do. When the autonumber gets set automatically (that's what autonumbers do), then that is done in code so it never will trigger anything like you are assuming. I already explained that in my previous post. You have disabled the autonumber in the provided screenshot. If you enable it, it will populate automatically and as long as you have the master/child links correctly set, everything should function correctly.

The only problem with your code posted in the first post is that you are testing if the (StudentBookIssue_ID.Value = True), which doesn't make any sense if the ID field is an autonumber. Autonumbers are numbers and not true/false values. So your logic is flawed. Since we don't know what the logic is supposed to be, you have to determine what you want to happen and adjust accordingly.

It looks like you could just set the checkbox default to True and be done with it. You seem to be checking that box no matter what.
 
Autonumbers do not execute code, events do. When the autonumber gets set automatically (that's what autonumbers do), then that is done in code so it never will trigger anything like you are assuming. I already explained that in my previous post. You have disabled the autonumber in the provided screenshot. If you enable it, it will populate automatically and as long as you have the master/child links correctly set, everything should function correctly.

The only problem with your code posted in the first post is that you are testing if the (StudentBookIssue_ID.Value = True), which doesn't make any sense if the ID field is an autonumber. Autonumbers are numbers and not true/false values. So your logic is flawed. Since we don't know what the logic is supposed to be, you have to determine what you want to happen and adjust accordingly.

It looks like you could just set the checkbox default to True and be done with it. You seem to be checking that box no matter what.
Thanks much appreciated for the info.
 

Users who are viewing this thread

Back
Top Bottom