Command Button to add userform data to datasheet (1 Viewer)

chrisjames25

Registered User.
Local time
Today, 02:50
Joined
Dec 1, 2014
Messages
339
Hi

I have a userform with a new product textbox and various validation controls.

Basically i want my Cmd_AddProduct button to do the following:

1. Pop up messagebox to say are you sure you want to add this new product name - I CAN DO THIS
2. Jump to next record in datasheet - this is the bit i am struggling with. Sure simple.

PLease can i have the answer in VBA rather than as a macro builder.

Cheers

CHris
 

Ranman256

Registered User.
Local time
Yesterday, 21:50
Joined
Apr 9, 2015
Messages
3,571
if you are adding a new product, there is no next record.

1. you can have a continuous form that shows records,
2. click new to open YOUR form to add new. (unbound form) save.
3. Then it closes form, and you are back to the list.

But click ADD button
ask then post data:
Code:
sub btnAddNew_click()

If msgbox("Add product:" & txtProd & "?",vbquestion+vbYesNo,"Confirm") = vbYes then
   docmd.Setwarnings false
   docmd.openquery "qaAddNewProd"    'run append query to add form data to table
   docmd.Setwarnings true
   me.close
endif
end sub
 

chrisjames25

Registered User.
Local time
Today, 02:50
Joined
Dec 1, 2014
Messages
339
HI Ranman

Perhaps didnt explain self properly as think you may have got the wrong idea (or maybe i misunderstood your answer).

I have created a userform linked to a Categroy Table.
I enter a new variety into a textbox.
If i click the new record icon at bopttom of form in the navigation bit it goes to next record. I want to achieve this by clicking a command button?

cheers
 

Ranman256

Registered User.
Local time
Yesterday, 21:50
Joined
Apr 9, 2015
Messages
3,571
if you enter directly into the cat table , then it is added. There is no point of adding it then asking the user NOT to add it.

If you want to add via an unbound form , THEN you can ask the user to add or not.
if so, run the append query.
 

chrisjames25

Registered User.
Local time
Today, 02:50
Joined
Dec 1, 2014
Messages
339
Are i see what you mean. I will give that a try and unbind the userform for now.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom