Modifying an addnew record button in two control form

xaysana

Registered User.
Local time
Today, 09:16
Joined
Aug 31, 2006
Messages
94
Dear All Please help,

I am very new to VBA. In fact, I've been a ordinary access user for years. Now just have a brainstom to learn about Module VBA. Just got a chance to create a simple Fixed Assets Database for a Project, already caught up in trouble.

Here it is:

In a data entry form: I created two tab control which links to the Assets table, this table has a field called CIATinAsiaCode defined as text type for a pramary key, then this field links to another tables as a relationships.

Here is what l'd like to modify:

1. When an addnew button is clicked, to insert new recordID into table the Assets table with consequential number.

2. Imagine that after filling up all data required into the second tab page. At the same time on inserting new record to Assets table, I'd like to move a cursor back to any particular field in the first tab.

I am quite convincing that this would be piece of cake for you but I can not ever dream of, would reverencially appreciate for your help.
 
On the AfterUpdate event from creating the new record, set focus to the control you want.

Assuming it's on the same form, not a subform, etc:

me!controlname.setfocus

Moving focus to/from a subform or subsubform is more complicated. First move focus to the parent, the next higher paret, if, any, then to the control. One can't jump directly to another generation; one has to pass through each generation.
 
Thanks for your assistance.

Yes, it is in the same form not a Subform.

In fact, I had followed your instruction, it is actually worked switch to the first a Tab control, however once it switches to the first tab, it doesnot create a new blank record instead appears the most current record just input, also popup with a message "Cannot go to the specified record"

What should I do next please?
 
Without looking at it it's hard to tell, but sounds like your "new" record might have some kind of indexing proiblem.

Can you post a snapshot of your form in design view (with the tab you moved focus to showing) and the form's VBA code.

I think that your error message might be firing on your entering a dulplicate index.

Maybe your form's recordsource in nonupdatable. Can you otherwise add new records?

I've had that message, but can't remember what fired it.
 
Please be with me, without your assistance I can not move any further.

Yes, after closing down the error message then went to click a New button to add new record it allows to add new record.

Also, I would like to disable Mousewheel, prefer to use Next or previous record buttons rather than Mousewheel.

I attached to you a formVBA and a snapshot of form.

Thank you and appreciate on your kindness help.

With best regards,
 

Attachments

  • snapshot of form.JPG
    snapshot of form.JPG
    98.2 KB · Views: 159
  • FormVBA.txt
    FormVBA.txt
    7.7 KB · Views: 163
Forget the form navigation buttons you added. Use the form's navigation buttons and some of your problems will disappear. They're not sized like your buttons, but they are very effective and are the widely used.

Navigation buttons, in and of themselves, are very complex.

If you committed to using then, you should search for ready made buttons with code appropriate already created. Navigation buttons are your search words.
 

Users who are viewing this thread

Back
Top Bottom