Modules & VBA :: Copy A Record Without Triggering Form Events

Dec 30, 2014

I have a form which has been in use for some time now, and works extremely well for all users; as part of a recent update to that form, I added a few events to various controls; most of them are message box prompts to remind the user to do something, but one is automatic entry of text into a memo field when another field is updated, and it is really this last one that is causing an issue.

There is a command button on the form which has an embedded macro, created using the wizard - it is probably the last, or one of the last few buttons that have a macro as opposed to VBA.

Essentially, when this button is clicked, I would like a duplicate of the current record to be made (thus giving it an Autonumber ID of its own), and if possible I would like this to be done without triggering any of the after update events on the form. Is there a way to disable these events and copy a record in its entirety, re-enabling the events at the end?

View Replies


ADVERTISEMENT

Events Not Triggering

Jun 23, 2006

Access front end, SQL Server backend.
----
I have a continuous subform (part of a tab control on a main form) whose name and sourceobject are both "sbfCannulae". There are about 10 fields on the subform, and all are bound to fields in a table. The primary key of this table must be generated by combining two other fields, which must happen just before the record is saved. (I know calculated data should not usually be saved in tables, but trust me. In this case it is necessary.)

Right now the user COULD enter data into the primary key-bound textbox, but since the user is me, I make sure not to do that.

When I enter data into all fields except the primary key, I get an error because the primary key cannot contains nulls...of course.

I use the following code to tell me when an event has been triggered.

Code associated with sbfCannulae:
Option Compare Database

Private Sub Form_Activate()
MsgBox "cann activate"
End Sub

Private Sub Form_BeforeInsert(Cancel As Integer)
MsgBox "cann before insert"
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
MsgBox "cann before update"
End Sub

Private Sub Form_Current()
MsgBox "cann current"
End Sub

Private Sub Form_Dirty(Cancel As Integer)
MsgBox "cann dirty"

End Sub

When I enter data into a new record, the Dirty event is triggered, but I cannot for the life of me figure out how to trigger any of the other events. No combination of values and nulls in any fields, clicking in other tabs, clicking to other records, or using the navigation buttons will ever trigger any events but Dirty.

The only msgbox I ever get is the one giving delivering the SQL error about the primary keys not taking null values.

What am I doing wrong?

-Matt

View 1 Replies View Related

Modules & VBA :: Filter Not Triggering On Form Open

Jul 28, 2015

we have gotten in to a routine of copying, pasting and bastardizing old databases instead of creating new ones from scratch - and we've had a problem recently where we've started off with one master database back in 2011, which has then been the base for practically every single major DB we've created ever since.So this month we've copied and pasted (again) and started adding new features to what's already there, and the thing has corrupted. I've copied and pasted the same version three times and added all the new bits, and the same thing has happened every time.

So this time I've copied and pasted and tried my best to clean up, get rid of the dead weight and (where necessary) create completely new objects, split into FE and BE versions etc, and I've reduced the overall weight of the DB by about 50%.Due to time constraints I now need to crack on and get this thing working again and, for the most part, it does - but now I'm having trouble carrying the filter over from the OnClick Event of a form button to the next form it's opening.

We're using the DB to record attendees at an Event we're running later in the year. This is the code that I'm running from the OnClick Event of the button on Form1:

Code:
Private Sub btnBkg_Click()
On Error GoTo Err_btnBkg_Click
Dim stDocName, vFilt As String
Dim vBkgRef As Long
Dim vContactID As Long

[code]....

You can see I've tried to use vFilt instead of the actual code for frmBooking's Where Condition, but for some reason it does not carry over to the form whichever way I try - when I open the immediate window and type ?vFilt it returns a blank entry. Not sure how to show the 'Where Condition' in the Immediate Window?Before Update, Open and Activate of frmBooking, but I'm hoping that the problem lies with what I've posted up here, as I don't want to get into posting the frmBooking code...

It may be worth noting that the button resides in the Header of a continuous form, with conditional formatting that changes the button caption depending on whether there is a value in the BkgRef text box of the record that has the focus.

View 3 Replies View Related

Modules & VBA :: Copy Record From One Form To Another?

Nov 14, 2013

ok so I have two forms open: One is a SP Bookings form with a subform SPDetails Query subform. The other form is the not connected/related SP Contacts Query form, to which users enter Full Name weight age ect. Need to copy the names of the new customers Full Name to the Lookup Contact Column in SPDetails Query subform. I got this far, with my trial runs are commented out. The only thing it does when I click on the button is move to new record on Sp Contacts Query Full Name and Copy the previous record. How do I get the button to copy the Full Name from form SPContacts Query.Full Name to the SPBooking Query.subform SPDetails Query Subform.LookupContact

Code:
Private Sub Command52_Click()
Me.Full_Name.SetFocus
DoCmd.RunCommand acCmdSelectRecord

[Code].....

View 3 Replies View Related

Modules & VBA :: Ignore Certain Events In A Form?

Apr 9, 2014

In my database I have module that checks if tick box is True and then closes all the forms and kicks the user out of the database. However in most of my forms, there is a custom Save command in the On Click of cmdSave button and the Form_BeforeUpdate. The save requires certain things to be true so naturally if a user has made a change to a record, the form won't allow you to close it if you haven't saved your changes or undone them.

Is there anyway I can get my module to bypass certain events in the form?

View 7 Replies View Related

Modules & VBA :: Mouse Events On A Form

May 27, 2015

I have a parts order form (FrmORDER)with a list of parts selected stored in it. e.g Part #, Part Description, Qty, Price etc

I also have assemblies stored with the same detail that are composed of individual parts.

What I would like to do is

Open formA if I do a single click (to select a new part or assembly)
Open formB if I do a double click (to open the contents of the selected assembly in the order form

It would seem that the following series of events occurs

When the user double-clicks a control other than a command button: MouseDown → MouseUp → Click → DblClick → MouseUp

Hence I can't actually open formB with a double click unless I remove the single click event.

View 10 Replies View Related

Modules & VBA :: Event Not Triggering When Clicking Search Button

May 23, 2014

I have the below VBA in a from for it to filter the records below based on the criteria:

Private Sub Search_Click()
Dim strWhere As String
strWhere = IIf(Len(Me.AssignedTo & "") <> 0, "([AssignedTo] Like ""*" & Me.AssignedTo & "*"") AND", "") & _
IIf(Len(Me.OpenedBy & "") <> 0, "([OpenedBy] Like ""*" & Me.OpenedBy & "*"") AND", "") & _
IIf(Len(Me.Status & "") <> 0, "([Status] Like ""*" & Me.Status & "*"") AND", "") & _

[Code] ....

When I click the search button nothing happens, is there something wrong with my code??

View 4 Replies View Related

Modules & VBA :: Copy Current Record From Recordset To Csv

Aug 4, 2013

I have a DAO.recordset called "rsSQLIn". This comes from a csv file by:

Code:
strSql = "SELECT * " _
& "FROM [Text;Database=" _
& strFolder _

[Code]....

While the validation runs a boolean keeps track of validated input and errored input.

After validation the validated input is dumped in the table.

Now what I want is de saving the errored record from "rsSQLIn" to be copied to a new .csv file.

The problem I have is that I cant seem to get the current record from the recordset "rsSQLIn". How do I reference this? I need the complete set of 24 fields being the same within "rsSQLIn"

View 3 Replies View Related

Modules & VBA :: Copy A Record As New And Change Certain Field

Dec 12, 2014

I am trying to copy a record as new record in vba in access so i make a button for the user so that they can copy a record each time and change a certain field if they wanted. How would i do that.

View 1 Replies View Related

Modules & VBA :: Copy Subform Recordset To New Record

May 8, 2015

I am trying to copy a subform record set from one record to the next record. The data in the main table is copied over using this method;

Code:

Dim v1 As Variant
Dim v2 As Variant
Dim v3 As Variant
Dim v4 As Variant

v1 = Me![Today's Date].Value
v2 = Me!Insured.Value

[Code] ....

Can I integrate the copying of the subform data to the new record with this or do I need something different, and if so what?

It's a many to many relationship and I've tried adding the following line to the code:

v5=Me![Endorsements Umb XS].[UmbID]
same=v5

and it works but it only copies the first record out of the set.

View 14 Replies View Related

Modules & VBA :: Copy And Paste Current Record Only To Excel

Jul 13, 2014

Its been a few years since I used Access, and despite searches I cant find what I'm looking for. I have a VERY simple form, with only one record on it - "address". I have some print buttons which will print that address to different size labels, and some navigation items, but only one actual record - which is "address" (in the table, this address is a MEMO)

I would like to have a command button that when clicked copies the current record, and opens an existing Excel Spreadsheet and pastes that address into (for example) cell C8

Can it be done easily? Is there a DoCmd.TransferSpreadsheet kind of secnario that works with current record only?

View 8 Replies View Related

Modules & VBA :: Copy / Paste Field From Previous Record

Jun 22, 2013

It is a continuous subform (Names: Form = ClientUpdate / Subform = ClientUpdateSub.

All of the data implicated here is direct and in the subform's query table including the button we want to program.

(This is my example but it wont stay in columns in this "post box" )

IDNo App _ID App_Freq App_Date GetDates Action_Date
22 18 56 21-Jun-13 BUTTON 14-Jun-13
21 19 56 16-Aug-13 BUTTON 9-Aug-13

*

The GetDates Command BUTTON should generate the red data above, like:

Private Sub GetDates_Click()

Go to a new record
Go to the field App_Freq and fill it with:
Copy/paste the data from the field of the same name in the previous record
Go to the field App_Date and fill it with:
data based on this calculation using the PREVIOUS record fields: App_Date + App_Freq (which are days)
Go to the field Action_Date and fill it with:
data based on this calculation: App_Date (of current record now filled out - step above), minus 7 (days).
End Sub

That's it!

All the dates format is set to medium date. An error message should come up in case App_Freq is empty, for example

Also note that the data can be manually changed at any time and should not revert to its last calculation. The button only generate data into a new record.

View 14 Replies View Related

Modules & VBA :: Copy Record As New In Large Number Of Tables

Jan 20, 2015

I have "Master" table with fields "Job No" and "Revision No". Both together is a primary key, so that combination of both cannot be duplicated. I have 100 other tables to be related with referential integrity(+update&delete) to Master for both fields. Apart from Job No and Revision No, all 100 tables have different set of fields which is why I had to come with so many tables.

Due to 32 limit rule, I had to come up with workaround method to have all 100 tables in the relationship. So, I created 5 other SubMaster1, SubMaster2, ...., SubMaster5 which are related to Master with relationship with referential integrity (+update&delete). Then I assigned 20 tables to each SubMaster so that 20 tables are related to each SubMaster table.

Whenever I create new record in Unit, the new record is generated in each SubMaster using update query for each SubMaster table. I have all the forms and necessary query laid out. The only missing part is being able to duplicate a record. I have limited knowledge in VBA, but I should be able to modify it to address to my requirement.

I want to copy a given record in Master, SubMasters and 100 tables as a new record. I need this feature so that I can select certain Job No and Revision No and copy that as a new Job No(assigned manually in a form) and 0 as the revision number. Possibly a button which will ask for new job number and copy everything from the active Job No and Revision No to a New Job No and "0" Revision No. The existing record may not be there on all 100 tables for the given Job No and Revision No. If it is there, then copy otherwise ignore for each of the tables.

I have a table "ItemList" which lists all the unique name of the 100 tables.

View 8 Replies View Related

Copy Button In A Form To Copy Fields To Other Fields In The Same Record

Sep 23, 2005

Hi there,

Can someone help me on this issue?

I want to copy Postal Address Information to Visit Address Information wthin the same record, in my Contact Database that I am building at the moment.

I want to copy 4 fields to 4 other fields within the same Record.

This the current code I use for the Copy-button:

---

Private Sub cmdCopyFields_Click()

Dim v1 As Variant
Dim v2 As Variant
Dim v3 As Variant
Dim v4 As Variant


v1 = Me!Field_a.Value
v2 = Me!Field_b.Value
v3 = Me!Field_c.Value
v4 = Me!Field_d.Value


RunCommand acCmdRecordsGoToNew

Me!Field_e = v1
Me!Field_f = v2
Me!Field_g = v3
Me!Field_h = v4


End Sub


---

The underlined part (acCmdRecordsGoToNew) is false part of this code, because it copies the Adress Info to a new record, instead of copying it in the same.

-Is there someone that can help me with this problem, to make the copy-button in the Form run properly?

-Are there other options to achieve te same?

I have put in a attachment, to give you guys a visual example of what I mean.



Thanks in advance,

Quinten

View 3 Replies View Related

Modules & VBA :: Copy Record N Number Of Times - Incrementing Date

Jun 3, 2015

Is it possible to copy a record 'n' number of times, incrementing the date by either days, months, weeks etc?

I have a regular payments table that will need to be edited at some point should either dates, or amounts change, but... regardless of the size of the table, it's not a problem, as these will be moved to a different table and deleted once paid.

Given the example, would it be possible to copy this record and additional 5 times, incrementing the date by one week.

View 11 Replies View Related

Main Form On Current Not Triggering

Nov 19, 2012

i have list box which lists all active records. raw source is based from Main Query which lists all active records from current user. on click even of list box i have macro that goes on record selected in list box, which is working fine.on current event of main form function is called. Main Query order by id Desc, list box order by is Asc problem is when i click on last field in List Box which takes me to record, On Current event does not trigger on main form. if i use Record Selector on main form to go to that same record,On Current triggers.

View 2 Replies View Related

Modules & VBA :: Loop - Copy Current Record By Number Of Times Specified In Quantity Field

Sep 20, 2013

I would like to do a loop but never done one before, basically i want to copy the current record by the number of times specified in a quantity field

So if the quantity field in the record says 5 then copy that record 5 times (I have managed to create the copy and paste code but dont know how to make it do it 5 times

Code:
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.GoToRecord , , acNewRec
DoCmd.RunCommand acCmdPaste

View 2 Replies View Related

Triggering A Macro To Occur When A Form Window Is Closed

Aug 17, 2006

Hi,

I am wondering whether it is possible to trigger the run of a macro when a form window is closed using the close button in the top right of a standard window?

If not, then is it possible to display a form in a window without the minimize, restore and close buttons?

I am currently using a setup whereby I have a button to close a form, and when clicked a macro is executed. However, the user could just as easily close the form using the close button of the window and the updates would not be performed.

Thanks in advance
Turbojohn

View 2 Replies View Related

Forms :: Copy Record Data To Another Table Through Form

Aug 1, 2014

I have a form with 2 subforms, each based on their own table. One displays categories of invoices (e.g. rent, electricity, etc.) including some details like monthly costs.

I would like users to be able to select one of those categories and copy this to another table, after which they can enter on what date the invoice was paid, to make a history of payments.

At first I based fields in the history table on fields in the categories table so that you could simply pick a category from a combobox. I had an after update event on that combobox that also automatically set the 'costs' combobox to the matching price.

Worked fine, but had one snag: if I update the costs of a category in the categories table (e.g. the rent goes up) then all the costs in the history table was also updated because the fields got their info from that table.

So now I no longer have field from the history table based on the other table, and want to use 'set value' to copy values from one table to the other. I'd like the user to be able to somehow select a category with a single click on a button, and getting the info for that category copied. However, how can I get access to know from which record I want the fields copied?

Or is there a completely different way to get a history of payments that works much better?

View 4 Replies View Related

Forms :: Copy Record On Form Based On Combo Box?

Mar 31, 2014

I have a form that i input information into. I have a combo box labeled Addendum, you can select "yes" or "no". What i would like to do is if user selects "yes" then a new record needs to be copied with exact information form original, with the excpetion of a field labeled "tape review #" 1403310000 for example. "-AD" needs to be added to this new record after the review number. Also the field "tape review #" is indexed not to allow duplicate numbers.

View 1 Replies View Related

Copy Field Data From Main Form To A Subform On Add New Record

Feb 25, 2006

I have a main form that has some sub forms on it linked by master child on PK. When I select a new record on the sub forms I want to take a date value from the main form and populate the value into a field in the sub form. How do I do this as I cannot see a new record event on the sub form?

help would be much appreciated.
regards

Peter

View 7 Replies View Related

Modules & VBA :: Copy Value From Current Form To A Table

Aug 27, 2013

I have a projects Database with: Projects_Table, Staff_Table.

Both tables has forms for data entry or update. Each project has many staff allocated to it.

In the Staff_Form I placed the Project_Code in the form heading section. The form opens based on a search criterion on the project_code so it shows the staff for that project only. The issue is when I try to add a new staff for that project on the Staff_Form, the project_code stays blank in the staff_table.

What I need is that the project_code in the staff_table for that newly added person to have the same project_code on the opened form. Simply to link the staff to the project they work in when I add them using the form.

View 1 Replies View Related

Modules & VBA :: Copy A Control In Form Design?

Oct 24, 2013

I need to duplicate a number of controls on a form. They are all acCommandButton types, but they have different images, sizes etc.

Anyway, my thought process was if I have a "template" acCommandButton then when I create my new controls if I could use this template then the code I have hanging off them (I have a function being called on the onClick event, borders are set to hairline, themes turned off and various other settings) would be copied. Save me trying to set them all individually.

So, my question is, can I "copy" a control in form design through VBA. Once I create the copy of the control I can then change the couple of properties I need to and "hey presto" I have skipped a load of settings that I don't need to set.

At the end of the process when I rename my form I can delete my template control and I have a working form.

View 7 Replies View Related

Forms :: Record Availability Of Volunteers For Different Events In Database

Jul 14, 2013

I am trying to create a database that will record the availability of volunteers for different events.

So far, I have used access to create an availability table, that contains fields for event, date, name, shift 1, shift 2, shift 3.

I now want to create a form that will filter this table for a given event, then layout the form so that names appear down the left, date across the top, and then the shift 1 to 3 fields (which are yes/no fields) to appear in the body of the layout.

This is so the organising team can quickly enter this information (received by phone, email, fax) into the database. I have had a go with subforms within subforms but so far drawing blanks.

View 1 Replies View Related

Changing Record Source - No Functions / Events Work

Oct 24, 2012

I have created a system consisting of a data entry form etc. It was originally connected to one record source exported from a sharepoint site.I had to add a field to the sharepoint site and so i created this additional field and re-exported the data and changed the forms record source and all occurences in the code of previous to new record source.

However, this change of record source produces the following error on every single event.The expression On Load you entered as the event property setting produced the following error: member already exists in an object from which this object module derives.

I tried to break the code as soon as it hits the load function to track the error - but it doesn't even run this function so the code is not executing at all.When i connect back to the old record source it works fine.

View 1 Replies View Related

Modules & VBA :: Before / After Delete Confirm Events

Oct 4, 2013

I'm using Access 2007..I have a table that contains transaction records from a bound form.When the user enters a certain type of transaction, I create a corresponding transaction in the after insert event.

Example
User record - tranId = 1, tranAmt = 10, tranType = DISB, tranAssocID = 0
My record - tranId = 2, tranAmt = 10, tranType = RECV, tranAssocID = 1

When the user deletes a record, I want to delete my corresponding record using the tranAssocID ( delete * from tran_tbl where tranAssocID = (the tranID of the user's record)

Problem:
1) I don't know how to save the tranID of the users record
2) I don't know how to reference the saved tranID in the delete statement.

I'm using the before delete confirm event to try to save the users tranID to no avail.I'm using the after delete confirm to delete my record in a case statement - acDeleteOK...I tried to save the value of the ID in the form (Me.tid) to a public long variable, a hidden field on the form, and a temporary variable to no avail.

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved