Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-25-2017, 02:52 AM   #1
chrisjames25
Newly Registered User
 
Join Date: Dec 2014
Posts: 319
Thanks: 3
Thanked 1 Time in 1 Post
chrisjames25 is on a distinguished road
Command Button to add userform data to datasheet

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

chrisjames25 is offline   Reply With Quote
Old 09-25-2017, 03:46 AM   #2
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 3,376
Thanks: 0
Thanked 746 Times in 731 Posts
Ranman256 will become famous soon enough Ranman256 will become famous soon enough
Re: Command Button to add userform data to datasheet

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
Ranman256 is offline   Reply With Quote
Old 09-25-2017, 03:56 AM   #3
chrisjames25
Newly Registered User
 
Join Date: Dec 2014
Posts: 319
Thanks: 3
Thanked 1 Time in 1 Post
chrisjames25 is on a distinguished road
Re: Command Button to add userform data to datasheet

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

chrisjames25 is offline   Reply With Quote
Old 09-25-2017, 04:10 AM   #4
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 3,376
Thanks: 0
Thanked 746 Times in 731 Posts
Ranman256 will become famous soon enough Ranman256 will become famous soon enough
Re: Command Button to add userform data to datasheet

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.
Ranman256 is offline   Reply With Quote
Old 09-25-2017, 04:12 AM   #5
chrisjames25
Newly Registered User
 
Join Date: Dec 2014
Posts: 319
Thanks: 3
Thanked 1 Time in 1 Post
chrisjames25 is on a distinguished road
Re: Command Button to add userform data to datasheet

Are i see what you mean. I will give that a try and unbind the userform for now.

chrisjames25 is offline   Reply With Quote
Reply

Tags
button , next data , userform

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with command button to open datasheet of contact names Lyndon000 Forms 5 12-05-2013 06:36 AM
Datasheet Command Button Richie2837 Forms 4 02-02-2007 04:26 AM
Help with a command button on a userform Justchris General 4 02-25-2005 12:10 PM
Command button in datasheet form ? novoiceleft Forms 4 02-12-2005 06:54 AM
command button not showing on form in datasheet view mtc67 Forms 3 06-21-2001 04:00 AM




All times are GMT -8. The time now is 06:33 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World