Please can someone help, I’m new to writing VBA code and got myself stuck. I have to use Access 2002 VBA.
I’m trying to move focus from one field to another, then another on a record in a subform, that is in datasheet format.
I have a record (row of info) in a subform that has the field BookedOutTo which after the user has finished entering a name no matter where they click on the subform it moves to a field called BookedOutBy, using Me!BookedOutBy.SetFocus in the On Lost Focus property.
This works
Then in the BookedOutBy field in the On Got Focus property I use code to get the user name of whoever is logged onto the computer and set the text of BookedOutBy to that. (ie it automatically enters the user name to log who did what).
This also works
However further along on this code I then try and move the focus to another field called BookedOutDate where I want it to automatically enter a date ( the intention was to just move focus after this to a QTY field, with no auto entry). However trying to set focus a second time fails and I get an error that says that BookedOutBy cannot get focus even though this was previously working. Despite the error message it does put the User name into the Field ?
I have tried putting the second Setfocus in the On Change property of BookedOutBy, but this also does not work. I tried making the Got Focus property change the name of a label and the On Change property to ask if the label has been changed before running the new set focus, but this also failed ( I think this is a timing thing as On Change seems to run after the first letter is entered, not when the auto input has finished).
Any help where I’m going wrong would be appreciated. All I want is to auto fill a few field before letting the user continue. So the main questing is how to a set a follow on setfocus command.
Thanks
Vsnow42
I’m trying to move focus from one field to another, then another on a record in a subform, that is in datasheet format.
I have a record (row of info) in a subform that has the field BookedOutTo which after the user has finished entering a name no matter where they click on the subform it moves to a field called BookedOutBy, using Me!BookedOutBy.SetFocus in the On Lost Focus property.
This works
Then in the BookedOutBy field in the On Got Focus property I use code to get the user name of whoever is logged onto the computer and set the text of BookedOutBy to that. (ie it automatically enters the user name to log who did what).
This also works
However further along on this code I then try and move the focus to another field called BookedOutDate where I want it to automatically enter a date ( the intention was to just move focus after this to a QTY field, with no auto entry). However trying to set focus a second time fails and I get an error that says that BookedOutBy cannot get focus even though this was previously working. Despite the error message it does put the User name into the Field ?
I have tried putting the second Setfocus in the On Change property of BookedOutBy, but this also does not work. I tried making the Got Focus property change the name of a label and the On Change property to ask if the label has been changed before running the new set focus, but this also failed ( I think this is a timing thing as On Change seems to run after the first letter is entered, not when the auto input has finished).
Any help where I’m going wrong would be appreciated. All I want is to auto fill a few field before letting the user continue. So the main questing is how to a set a follow on setfocus command.
Thanks
Vsnow42