473,395 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

macro adds new records and fill field

2
how can i by clicking a command button to add records in a subform and get filled with a certain value?
Eg: Click cmdToevoegen> adds 3 new records in subform with the following values​​: Value1 , value2 and value3.
Apr 2 '14 #1
2 1601
zmbd
5,501 Expert Mod 4TB
bresca:

We need to clear up the terminology:
Access has two programing languages.
1) Macro - best avoided unless makeing a sharpoint publishable application
2) VBA - what most of us use to automate tasks such as you suggest in your post.

Next:
subform : although the methods to accomplish what you want are simular, we need to make sure that you mean subform and not a form in general. That is to say, you have a parent form and within that form you have a second related form (subform).

Finally:
We need to understand from where the values to enter into the new record will be obtained.

The general format for the code will be:
Insert the command button into the form
Cancel any wizards
Open the properties of the command button.
Preferably change the control name to something usefull avoiding reserved words and tokens.
In the events tab, on click event, button [...], select code not macro.
In the code
There are several methods to add the record and this will depend upon your reply as to how the values are obtained as the easiest method.
Most assured method is to open a DAO record set on the table where you need to save the data
Using the add.new method create the record and save/update
close the record set
force the subform to requery.

Please understand, we do not normally write code. If you will write out your code, follow the basic troubleshooting steps found here: > Before Posting (VBA or SQL) Code and then post back your code with specfic details as to what it isn't doing and what it should along with any error messages... we can help from there.
Apr 2 '14 #2
bresca
2
I will do my homework better
Apr 2 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Anita Mossey | last post by:
I have a table named tblSkills consisting of two fields named ContactID and Skills. The table does not have a key. The NotInList code below is for a subform that consists of a text field with a...
2
by: Dannic | last post by:
I need to fill a table with values. The table has about 6000 records but the records will not have the same value in this field. I thought I had figured out a way to do this easily but it is...
2
by: Izod | last post by:
I'm new, hope I describe my dilemma ok. I've got a large DB from the County. They have the "house Number" in the same field as the Street Name. It is always the 1st 4 characters followed by a...
2
by: Steve | last post by:
How can I fill an empty field (FieldA) in a table with random integers between 1 and 11? Thanks!
1
by: Conor13 | last post by:
I have created a Form and I want the users to be able to press a comand button and have six of the eight fields populate with the last value added. The macro I tried to use would go to a new record,...
9
by: DAHMB | last post by:
I have a Report in which I have one of the fields set up to launch a form with the On Click event. I would like to have the form launch and auto fill a field with the value of the field clicked in...
5
by: special1 | last post by:
I would like to be able to auto fill field B with contents of Field a when Field A is a specific word, e.g DNA in Field A would apply to Fields B, C, D etc. Any ideas?
1
by: bytes access nubie | last post by:
Hello. I'm trying to create one macro in Access 2003 that will delete a field (called ID) in a table. I then need a separate macro that will *add* a field back in called ID w/type of autonumber. I...
2
by: MyWaterloo | last post by:
Ok. I have a form with a field for a sampler's name, number, and email address. The sampler's name is selected from a combo box that references a table with name, number, and email. I want to be...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.