Modules & VBA :: Update Field On Exiting A Record

Jul 11, 2013

I need to update a field with the contents of 2 other fields when exiting a record. The fields (ItemNo) and (LotID) need to create or update the field (LotCode).

i.e.: ItemID (GM-235), LotID (26) will result in LotCode (GM-235-26).

I currectly use a Update Query that uses the expression:

[products].[MasterPN] & "-" & [lotid] in the lotCode Field - "Update to".

Unfortunatly, I am using a button on my form that executes the query, but it updates all the records and although it runs very fast, I would rather have it perform this task automatically when I leave the record.

View Replies


ADVERTISEMENT

Modules & VBA :: SQL Update Query To Set A Record Field To Null?

Jul 11, 2013

On a push of a button from a form, I want to locate specific records within the table and update a field to Null if it matches a name

Dim strSQL As String
strSQL = "UPDATE tblmaster SET Score = "" WHERE [AdvocateName] = 'Anna Maria'"
DoCmd.RunSQL (strSQL)

I'm certain I don't have the syntax correct between the Set to Null and WHERE clauses..

View 4 Replies View Related

Record Users Entering And Exiting Database

Jul 7, 2015

Background info:
Split database
Back end on network
Front end on individual machines

I have a main menu form that opens up when opening Access.What I'm thinking is have some vba in the OnLoad Event of the main menu that Grabs the User and Time and track this to a table.When the database closes(Is there an OnDatabaseClose Event?), I'd like to track the User and time as well.

LogID(Autonumber)
User(text)
TimeIn(Date)
TimeOut(Date)

View 11 Replies View Related

Modules & VBA :: Update Specific Record In Table Using Unbound Field On Form

Dec 4, 2013

How to do an UPDATE using VBA on a form to update a specific record on the table using an unbound field on the form to filter the update.

Every time the code runs, it tells me: Run-time error '3144': Syntax error in UPDATE statement and takes me to the "CurrentDb.Execute strSQL, dbFailOnError" line at the end of my sample below.

Here's my code:

Dim strSQL As String
Dim strCriteria As String
strSQL = ""
strSQL = strSQL & " UPDATE [tblTicket] SET"
strSQL = strSQL & " ([UpdatedBy], [AssignedTo], [Requestor], [Dept])"
strSQL = strSQL & " Values"
strSQL = strSQL & " ('" & unbEnteredBy & "','" & cmbAssignedTo & "','" & cmbRequestor & "','" & cmbDepartment & "')"
strSQL = strSQL & "Where [tblTicket]![DateTimeOpened] = #" & FORMS!frmTicketTracker.unbDateTimeOpened & "#;"
CurrentDb.Execute strSQL, dbFailOnError

View 9 Replies View Related

Modules & VBA :: Make Certain Fields Required To Be Completed Before Exiting?

Jun 28, 2013

How do you make certain fields "required" to be completed before exiting?

View 3 Replies View Related

Modules & VBA :: Running Update Query On Record And Have Form Show Updated Record

Jan 26, 2015

i want to be able to create an On Click Event when pushing a command button that will run an Update query to update a record and after it has been updated that specific record will pop up on a Form and be displayed. i know a different way is to run the Update query and then have it displayed in a Select query but i want it to be displayed on a Form instead. is it possible?

View 4 Replies View Related

Dynamically Update Field Of A Current Record Based On Previous Record

Apr 30, 2007

I need a way to dynamically store a particular value in "field_2" of the CURRENT record depending on whether or not the value of "field_1" of the CURRENT record is identical to the value of "field_1" of the PREVIOUS record within the same table. The table is sorted on "field_1".

So, if the value of "field_1" in the CURRENT record is "ABC" and the value of "field_1" in the PREVIOUS record is also "ABC", then store a value of "PPP" in "field_2" of the current record. IF on the other hand, the value of "field_1" in the CURRENT record is "ABC" and the value of "field_1" in the PREVIOUS record is "XYZ", then store a value of "WWW" in "field_2" of the current record.

I have a report that will use these results to count only the number of records that have a "WWW" in "field_2".

Is this doable, maybe in a query somehow?

I should add that whatever the solution, it needs to be compatible with Access 2000.

View 1 Replies View Related

Modules & VBA :: Lock Record After Update

Mar 2, 2015

I have a form in datasheet view and on that form I have a yes/no tick box is it possible that when the tick box is ticked it locks the line from further entry.

View 3 Replies View Related

Modules & VBA :: Update Record With Info From Another Table?

May 12, 2014

I have a database which tracks product batches test results and then any reported issues.

I have one table tblOne with [Batch Number] and [Release Time/Date].
The 2nd Table tblTwo [Problem/Issue] at [Time/Date].

What i need to do is get the last batch number from table one which would have been released.

Example:

Batch: 275 Released: 21/09/2012 06:15
Batch: 453 Released: 30/09/2012 07:20

Problem: Wrong Batch Time/Date: 21/09/2012 08:20 Batch:????

How would i update table with correct batch in tblTwo

View 3 Replies View Related

Modules & VBA :: How To Get Autonumber ID Before Update / Save Record

Mar 27, 2015

I wanted to get the autonumber ID before a record was saved to the table. My fields are on a form that is linked to the table. Maybe my solution is not the most elegant but it seems to work.

I messed around and came up with this solution: it creates the next record and captures the autoID then increments it and creates the record we will actually use. Since we know the current autoID we know 100% the next will be the current+1

Code:

' Code by Witchcraftz
' Button event to add new record
Private Sub cmdAddRecord_Click()
Dim strID As String

[code]...

View 2 Replies View Related

Modules & VBA :: Record Count After Filter Update?

Apr 1, 2015

I have this on the Form - On Current Event to show how many records I have on the Form, However when the employee filters the combo box's I want the record count to show the current records when they finish each filter. At the moment it just shows random numbers.

PHP Code:

Private Sub Form_Current()       If Me.NewRecord Then        Me.lblRecordCount.Caption = "New Record"     
Else        Me.lblRecordCount.Caption = _         "Record " & Me.CurrentRecord & " of " & Me.Recordset.RecordCount     
End If    End Sub 

View 4 Replies View Related

Modules & VBA :: Update Combo Box After Adding A New Record

Mar 12, 2015

I have lots of combo boxes in my forms that are mostly limit to list as I want the people entering the data to actually add the full details of a client or supplier or whatever instead of just typing the information in over and over again. if the person/client/supplier is not in that list I have a button that will pop up a form so they can add a full new record but I need it so when they add the new record it will show up in the combo box in the intial form once it has been saved and closed without having to also close that initial form and reopen it or manually refreshing it.

right now I am using an if statement on the save button on my popup form that looks at what form is open and if that form is open then it refreshes that form after the save and closes which works fine but adding this to every form and combo box combination is very tedious, so I thought I would ask here, what is the best way to update combo boxes after and new record has been added via another popup form?

View 2 Replies View Related

Modules & VBA :: Comparing 2 Record Sets And Update Them

Feb 12, 2014

i have 2 recordset and i need to compare the two. If a record doesnt existing i need it to be added I have VBA that works but it seems very slow. Is there a better way of doing it

Dim rs As DAO.Recordset
Dim rs2 As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * FROM ExorData")
Set rs2 = CurrentDb.OpenRecordset("SELECT * FROM MainForm")
Dim TJb_Main, TJb_new
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst

[Code]..

View 14 Replies View Related

Find Record And Update A Field

Jan 29, 2014

Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Complaint", dbOpenDynaset)

[Code] ....

I find the record, and then try to update a field. The drop down menu field gets updated after it is initially changed from blank to a value, but it never changes after that though the re!C02 field has the correct newer data when I change it again.

View 14 Replies View Related

Modules & VBA :: Loop To Update Recordset Only Reaches 1st Record

Mar 13, 2014

I found this code and have substituted parameters to suit my own needs however the loop is not working. Only the first record in my recordset (which is a test recordset of only 3 records) is being updated.

Also, for testing only, the edit or update being applied is trivial: Description = "WHITE RESIN". If i can get the loop to work I want to substitute higher functionality to the module.

Private Sub Update_Click()
Dim dbs As DAO.Database
Dim rsQuery As DAO.Recordset

Set dbs = CurrentDb
Set rsQuery = dbs.OpenRecordset("qryRmResin", dbOpenDynaset)

[Code] .....

View 14 Replies View Related

Modules & VBA :: How To Bypass Before Update Event When Record Is Deleted

Sep 21, 2014

I have a database which is slowly evolving. Users needed a feature to delete some records without a trail and some with a trail from the form. So I added an apply action field in the subform using which they can delete a record without a trail and if they wanted to keep a trail they could do that too. When user selects "Delete Violations as it was entered in error" the system deletes the record completely which is what everyone wanted.

After six months of use now I am asked to add an audit trail. I managed to do that also. I also looked at Browne's method but my data structure does not match the requirements for that method. I used an alternate method. It works as intended except when a record is completely deleted using the code I mentioned above. Then it goes in the infinite loop. I somehow need to bypass the before update event so that the function to write the audit trail is not called.

I have attached the database ...

View 14 Replies View Related

Modules & VBA :: Loop Through Records And Update Listbox In Each Record

Sep 11, 2013

I have a table with a multi-select listbox as one of the fields. I want to loop through the recordset (table) and changes the listbox selections for each record.

To go into a little more detail, the table (tblEmail) has a field (Label) that is a multi-select listbox. The listbox pulls from another table (tblLabel). I want to loop through records in tblEmail and edit/change the Label(s) for each email though VBA.

I've tried doing something like this:

Code:
With rst
.MoveFirst
Do Until rst.EOF
.Edit
!Label.Selected(0) = True
.Update
Loop
End With

However I get an error that says "Run-Time Error '438' Object doesn't support this property or method" ...

View 2 Replies View Related

Modules & VBA :: Update Field Value Based On Another Field

May 11, 2015

I have the following fields in an A2010 form

PaymentMethod
Total
InstalmentAmounts
OurFee

InstalmentAmounts field is populated based on the results of PaymentMethod which is a combo box

Here is the current code

Select Case Me.Payment_Method.Value
Case "Three post dated Cheques"
'If three payments by cheque
Me.InstalmentAmounts.Value = Round(Me.Total.Value / 3, 2)

In some cases there will be a few pennies that the client "overpays" because the instalment amounts will not add up to the Total. I need to add up the TotalInstalmentPayments to find out what the client actually pays and then add the difference between TotalInstalmentPayments and Total to the OurFee field

So

Total = 500.00
Payment Method = 3 instalments so
IstalmentAmounts = 166.67 (rounded) so client pays 500.01 so the 0.01 needs to add to the OurFee field.

View 4 Replies View Related

Modules & VBA :: Update Record Based On Related Records Completed

Dec 4, 2014

I have 2 tables, one is like a main table, containing all of the main data, such as a Job Number, Customer, Quantity, etc. I have a second, related, table that acts a breakdown of information. There may be several related records to one main record, it entirely depends on the nature of the job.

What I'd like to do is run a function that looks at a main record, checks if all the related records COMPLETED field is ticked and then tick a field in the main record. I only want it to do this for records where all of the related records are COMPLETED.

View 3 Replies View Related

Modules & VBA :: Match Partial Text String And Update Record

Jun 13, 2013

I am provided a spreadsheet that contains multiple rows of similar data; each row/record represents a different stage in the process of financial transactions (requisition, purchase order, & voucher payment). Each financial transaction has these three records, with the amounts in one of three columns (pre-encumbrance, encumbrance, and expense), depending on the process.

What I am really after is the fuller, more detailed description that is apparently only available for the two records I don't want to import into the database (which is tracking only expenses and not the other two stages of the process). There is apparently no way to cross-reference these multiple rows due to the way the original database was designed (and we apparently have no control over this).

After importing the spreadsheet into Access, I would like to match the partial text string (truncated description) to the full description in another record, and update the record with the truncated description to the full description. To make mattes more complicated, I will also have to match values in the "pre-enc" or "enc" field with the "exp" field across these three records to make sure the correct descriptions are being matched because the truncated description will match multiple distinct records with the longer description.

TypeDescrPreEncEncExp
VOUJsmith-Instructor, 12/16/13$0.00$0.00$45.00
POJSmith-Instructor, 12/16/13, Course1, Parking($45.00)$0.00$0.00
REQJSmith-Instructor, 12/16/13, Course1, Parking$0.00$45.00$0.00
VOUJsmith-Instructor, 12/16/13$0.00$0.00$221.13
POJSmith-Instructor, 12/16/13, Course1, Lodging($221.13)$0.00$0.00
REQJSmith-Instructor, 12/16/13, Course1, Lodging$0.00$221.13$0.00

View 5 Replies View Related

Forms :: Force Update Of Field Before Record Is Saved

Aug 1, 2013

How can I force a field in a form to be updated before the record is saved / changed?

For instance I have a form with information on it and I want to ensure that any time the form is updated the user fills in a section providing the date and by who it has been updated by. I dont want the record to save unless that information has been filled out, and I also want it to take you to the field if you press save and it hasnt been filled out along with an error message.

To try and be a bit clearer. At current I have a Save and New button. This saves the form if dirty and opens a new record.

I want to add in the step that if record has been changed and FieldA has not just been updated then go to fieldA (Showing a message box). If FieldA has just been updated then save record and open new as normal.

My current save & new button properties are as follows (in Macro Editor)

On error Go To Next
If [form].[dirty]
RunMenuCommand Command SaveRecord
End If
If [MacroError].[Number}< >0
Message =[MacroError].[Description]
Beep Yes
Type None
Stop macro
On Error
Go To Fail
Go To Record
Record New
Go To Control
Control name Resort Code

View 3 Replies View Related

Modules & VBA :: Update SQL Only Updating Field Value To 0

Nov 20, 2014

When I try to run a simple update query written in VBA I get no errors but the field that I am trying to update just gets a 0 instead of the appropriate ID that I am passing.

Code:
Function ExtractProjects()
On Error GoTo ErrHandler:
Dim db As Database, rs As DAO.Recordset, rs2 As DAO.Recordset, var() As Variant, i As Long, qdf As DAO.QueryDef, ii As Long
Set db = CurrentDb

[code]....

The funny thing is if I run the query itself it works by using a parameter query but when I try and run it like this all I get is 0's in the field that it's supposed to be updating.The field [(SDSK) Charges Master].PID properties are as followed and is a linked table:

Type: Integer
Indexed: Yes (Duplicates Allowed)

A debug.print of the results of the query trying to be ran is the follows:

Code:
UPDATE [(SDSK) Charges Master] SET [(SDSK) Charges Master].PID = 1 WHERE ((([(SDSK) Charges Master].[IBB Date]) Between #10/24/2014# And #11/19/2014#) AND (([(SDSK) Charges Master].[Charge Num]) Like '*BAA*' And ([(SDSK) Charges Master].[Charge Num]) Is Not Null));

As you can see it is providing a number to be set to but instead it just fills it in with a 0.

View 4 Replies View Related

Running A Function When Exiting Db

Apr 20, 2005

Hello All

The problem that I am faced with is that I am try to automate a function that I have created that exports my access tables into XML. The function works great but now I want to take it to the next step. What I want to do is when a person exits my database I want the db to run this function before exiting so that all the new information is updated in the xml files. Any help would be highly appreciated.

View 3 Replies View Related

General :: Update Record ID To Another Record ID In Same Table And Update Related Records

Aug 22, 2013

I have a table called tblCompanies. When a company acquires another company, I need a method by which the acquired company's CompanyID (PK) can be updated to the new company's CompanyID (PK). I also need to be able to update all related CompanyIDs (FKs) to the new value in related tables.

In cases in which the new company does not have an existing record, there is no problem: the company name simply gets changed to the new company and the existing CompanyID is maintained. I then use an audit table and Track Changes function to keep track of the company name data and a union query to keep the old names in the selection lists.

The problem is when both companies already have existing records in the table.

So, let's say I have records for Company A and Company B. Company A merges with Company B and Company B is now the main record. What is the best, simplest and easiest way to update the CompanyID (PK) from A to B and change the CompanyID (FK) to the new value in all related tables?

I am envisioning a pop-up form that directs the user to select the new company and then an update query happens behind the scenes... but exactly how does the criteria for the update query get selected and how do all the related tables get updated? My vba skills are pretty basic, will I need extensive coding to do something like this?

View 6 Replies View Related

Unbound Text Field In Continuous Form: Update One Record, They All Get The Same Value

Feb 20, 2006

Hi,

I want to show some text from another table based on the values of the bound fields in each record of a continuous form. I thought it would be easy, but I can't get it to work.

I step through the records in the bound recordset and use some of the values to query another table. Then I use the value from the query to populate the unbound text field.

It works fine for each record. But every time the unbound field is updated, all the records in the continuous form are updated.

I'm stuck on this one. It's probably something simple to fix - if you know what to do!

Do you have any suggestions?

Thanks!
-Daniel

View 10 Replies View Related

Unable To Update A Field In Record In My Form After Selecting From Comboox.

Apr 25, 2005

Trying to update a field in a record in my form after selecting from a comboox.

This an orders form with a record per row for order items. I select the product from a dropdown list which is populated by a dynamic query from the afterupdate event on another combo. When I do the selection access reports the following error:
Runtime error 3331
to make changes to this field, first save the record


Debug takes me to the line :
Me!product_id = DLookup("product_id", "products_table", myvar)
from :
[code]
Private Sub comboProd_description_AfterUpdate()
Dim strFilter As Integer

comboProd_description.Value = comboProd_description.Column(1)

myvar = comboProd_description.Column(0)



Me!product_id = DLookup("product_id", "products_table", myvar)

[end code]

I'm lost as to what to do (no such thing as beginners luck!!). I'm not even sure if the error is from the combo box or from the field that it is trying to update (product_id)

Thx for looking

Kev.

View 1 Replies View Related







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