Topics Search

Create a new record using a macro?

Create a new record using a macro?
Views: 41
I'm building a relocation database. It is built similarly to the expense reports template already in Access 2007. I have a main form "Expense report" and a subform "Expense Details".

On the employee table Clock # is the primary key and cannot be duplicated. What I want to do is create a new expense report for each new employee (a dummy record to populate a zero value for each category of expense type).

So when I enter the employee and save the record it would automatically create a record with all the specified values, only changing the clock # (as input on the employee form).

I don't want to build the default values because each employee may have multiple expense reports with different expense types.

My thought would be to copy the entries in say "record 4" (autonumber field), only changing the clock # as input on the employee form.
Sponsored Links:

Similar posts...


Macro to open form to a particular record

Macro to open form to a particular record Icon
I have two forms: "Employees" & "Employee Badge".

I want to create a button in "Employees" form and press it, so that "Employee Badge" form opens displaying only the record that was on the "Employees" form at the time I pressed the button.

I have created a macro to do this. The "Action" of this macro is "OpenForm".

Can someone please tell me what I need to put in the "Where Condition" of the macro?
Or is that "something" entered in "Filter Name" of the macro?

Printing in Landscape via an Embedded Macro

Printing in Landscape via an Embedded Macro Icon
I created a form and added a button with the embedded Macro that prints the current record only. The macro arguments a select record, print record. My problem is that it prints the record in portrait. I need it to print landscape. How do I change it from portrait to landscape?

add duplicate of last record and display in new form

add duplicate of last record and display in new form Icon
I have a database that will be used for scheduling of training courses. I need to be able to create a duplicate record of data entered in a form when a command button is clicked to open the same form with duplicate data that the user can then modify.

For example, there may be multiple instructors involved in training a particular course, and they should be able to locate a scheduled course in the database and when they view the record in a form, click a button or check a box that will trigger a macro that creates a duplicate of the current record.

There is probably a better way for me to explain this, but if you can help me with the SQL string or macro to accomplish this,

Store the date and time when a record is modified

Store the date and time when a record is modified Icon
You can keep track of when records in a table are last modified, by using a form with a macro. When the form is used to modify a record, the macro stores the date and time in the table. Only the most recent modification date and time are stored.
In this article
* Overview
* Before you begin
* Step 1: Add timestamp fields to a table
* Step 2: Create a macro that records the date and time
* Step 3: Add the macro to a data-entry form

Navigation in a table problem

Navigation in a table problem Icon
I have created a form for input/edit and inserted navigation arrows to move to the next or previous record. I want to move to the next alphabetical record but the embedded macro moves to the next physical record.

As a new record may have been added it is physically out of alphabetical sequence, even though a sort will show a table in alphabetical order. I suspect the command "next record" in the macro is the problem.

Macro Conditional If Record Not Found

Macro Conditional If Record Not Found Icon
I've been trying to make a macro conditional that attempts to find a record in query X and if no such record exists, to go to form Y, however, if a record does exist, go to form Z. If I only want form X opened if such a record does not exist, wouldn't I use a conditional to cross reference the entry on a form "A" with the selected field after the FINDRECORD?? Is there an easier way?

2010 VBA "do while" code in a macro

2010 VBA "do while" code in a macro Icon
In Access 2010, want to run perform a "do while" loop in a macro. I understand VBA is the way to do this. So, I think I want to run a VBA script in a macro.

This Macro runs against a Form that has a SubFrom (MainForm named "Expense ID" & SubForm, "Expense"). Macro is initiated by pressing a button.

I would like help with some VBA code showing how to perform the following:

1. Evaluate a field ("Activity") in the first record of Subform ("Expense") against condition "Is not Null".

2. If condition is true, set value of another field ("Post") in the same SubForm record to "1".

3. Move to next record and repeat steps 1 & 2 until all Subform records are evaluated.

4. Return to macro that initiated the VBA script to perform the next action in the macro.

macro equivalent of If Is Null

macro equivalent of If Is Null Icon
If isnull(Field1) then

open form

end if

The open form exists as part of the button creation as a macro.

in the macro am going to insert a record at top to set up this conditional.or add the conditional column ? not sure how this is done in the macro world.

Macro to add and clear fields

Macro to add and clear fields Icon
Macro to add and clear fields - I added a new "add record" button and this time I am controlling it using the macro, it saves data to its table but does not clear thereafter, so I have to manually remove what was typed in.

How can I add another macro to add record to table and the clear it off the list boxes or fileds ?

Emails with a Macro

Emails with a Macro Icon
I currently have a Macro called by a "save/email" button. This macro will email (EmailDatabaseObject) the current form out to several users as a .pdf. In design view of this macro, there were only a few items available.
Object Type, Object Name, Output Format, Subject, Message Text, etc.

Is it possible somehow to modify this macro to include the current record number or another field? So the email recipients wouldn't have to open up the .pdf? For example, the message text of the
email would include "09012A0000". Or, the .pdf attachment would be the name of the record?