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 Replies


ADVERTISEMENT

Forms :: How To Copy Unbound Text Box On Form To A Current Record In Table

May 17, 2015

I created an unbound text box on a form that automatically pulls the current logged in user by using this:

Private Sub Txtuser_Click()
Me.Txtuser = Environ("Username")

The form grabbs the logged in user with no problems, however, I ultimately want this information to also end up in my table. So the form has three boxes (to keep it simple). The user will type their first name and last name manually on the form which the record source is this "table" where their name goes to the table last name =Field 1 and first name=Field 2 respectively. I want the unbound box from the form to place the logged in user in Field 3 for the current record.

View 5 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 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

Copy Current Record To Different Table

Dec 4, 2006

Is it possible to copy the current record on a form to a different table?
Example:

Form Name = Training Orders bound to a table with the same name.
2nd Table Name = History

I need to export certin fields from the Training Orders Form into the History Table. Below is the way I am trying to make it happen, but it does not work.

With Me.RecordsetClone
.AddNew
![Forms]![History]![Last Name] = Me.[lastname]
.Update


Me.Bookmark = .LastModified




End With


End Sub

View 1 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

Modules & VBA :: Code To Copy Partial Data To Another Form / Table

Jul 16, 2014

I have prepared a table in a database which includes a yes no box to one of the fields.

The idea of the yes/no field is that this is recording if the record is awarded. What i would like to achieve is that if the yes no box is checked "True" i would like to be able to copy some of the data from this table into a new table and that the form associated with this table opens up to enable the user to populate the remaining fields.

I believe i need to run this as an on click event procedure but cannot identify the code to enable the data to be copied accross to the other table.

View 14 Replies View Related

Forms :: Button To Copy Values From 5 Fields In Current Form To New Form

Sep 30, 2013

I would like to create a command button on my form that copies values from 5 fields in the current record into a new record leaving all the other fields blank except for the new record ID.

The fields that contain the data that I want copied into a new form are:

1. Member_Name
2. Member_ID
3. Account
4. UBH/PBH
5. Assigned_WRCA

View 8 Replies View Related

Modules & VBA :: Table Relationships And Nested Forms - Copy Sub Form Records

Aug 3, 2015

I've attached screenshots of the table relationships and some nested forms that I need to discuss in my database.

If you look at the forms screenshot you'll see I have a main form "business/cmc issues" that uses a combo box to select a business name; nested into that I have a second form "policy issues log" that holds details of policy issues about that business; then inside that I have a sub form "issue updates" that records brief details about the actions carried out in trying to resolve each policy issue.

The same policy issue can affect more than one business (because of a relationship between the two companies etc) but still needs to be viewed separately. So for example in the business selector combo box I might have business "ABC". In the policy issue it might say "doesn't pay on time". The "doesn't pay on time" issue might also apply to business "123" and so if I picked that business from the combo box you'd see the same policy issue.

Because it's the same issue for two separate businesses, the actions carried out will be the same, so what I want to do is, after a new action is carried out (where relevant) to be able to click a button that would run some code that copies the actions entered in the sub form for business ABC and pastes them into the sub form for business 123 where the product area and policy issue are equal. This is to avoid having to enter the same data twice.

View 3 Replies View Related

Modules & VBA :: Save As Dialog Box - Allow User To Save Copy Of Current Database At Desired Location

Feb 12, 2014

So I have this relatively simple problem: I need to create a button that once clicked will open the Save As dialog box and allow the user to save a copy of the current database where he wishes. The filename should contain todays date in DDMM format along with some pre-set text e.g. DDMM PresetText.

I am using Access 2010.

View 2 Replies View Related

Modules & VBA :: Copy Record To History Table And Then Delete It From Main Table

Jul 9, 2014

I have a form with a sub form. when a record is choosen in a combo box the sub form is filled out with a record.

what I am trying to do is have a button that will copy that record to a history table then delete it off the the main table.

I cheated by using the wizard to get the code to delete the record but I am having troubles modifying the code to copy that record to the history table. Here is the code below. I have tried to insert code in several places but it just errors out.

'------------------------------------------------------------
' Master_tbl_sub_fm
'
'------------------------------------------------------------
Function Master_tbl_sub_fm()
On Error GoTo Master_tbl_sub_fm_Err
With CodeContextObject
On Error Resume Next

[Code] ....

View 8 Replies View Related

Modules & VBA :: Copy Structure Of A Table To Make A Temp Table

Apr 20, 2015

I'm trying to copy the structure of a table to make a temp table. I'm using CopyObject (which also copies the data). So when I delete the data from the temp table, it also deletes data from the source table. Is the data linked? It should just be deleted from the temp table. Below is the beginning of the code. I've stepped through, and at the last step shown, the data in the source table deletes.

Code:
Dim strFile As String
Dim temp As String
Dim tbl As String
Dim db As DAO.Database

' error handle
On Error GoTo F_Error

[Code] .....

View 3 Replies View Related

Modules & VBA :: Copy Value To 2nd Table

Jun 18, 2014

I have a database with two tables, and a form that is bound to the 1st table. I have a duplicate record button on the form. One of the functions I want to happen is when the duplicate button is pressed, one value is copied from the form and added to the 2nd table. The tables are basically set up the same with an ID column which is the key and an autonumber, and the second value is a number. So I want to copy the number to the other table and add a record. What is the best method? Can I use an insert into and just copy from a variable, or is the better method with a recordset. Either way, I have not been able to figure this silly thing out and it is preventing me from moving forward with this database.

View 11 Replies View Related

Modules & VBA :: Copy Records To 2nd Table

Mar 28, 2014

I'm getting myself into a bit of a muddle.

I have four tables:
tblinvoice / tblinvparts
tblquotes / tblquoteparts

when I open the tblinvoice form it has tblinvparts as a subform. tblinvoice has a listbox that lists quote numbers linked to vehiclereg. I have a button on the tblinvoice that will open a popup tblquoteparts continuous form linked to the quoteid on tblinvoice. These filtered records have a select button so I can select all or some.

I have now got stuck as I need a button on tblquoteparts popup that will copy the selected records from tblquoteparts and paste them into tblinvparts where quote (on tblequoteparts)=quoteid in tblinvoice.

In a nutshell, I would like to copy selected records from tblquoteparts to tblinvparts.I need to duplicate the records because only 10% of invoices are generated from a quote and the quote parts/prices may differ from the final invoice.

View 9 Replies View Related

Modules & VBA :: Copy Field1 To Field 2 In Table

Feb 20, 2015

I want to save the timestamp created in a table when a user opens the database. My vba saves the computer name and user name and sets the currentuser = yes. The table is mysql odbc, and has the requisite timestamp and id fields. I have a form that I can open that shows who is online at that moment. When a user closes the database, the currentuser field is set =no. All of that works well. Now, I have added a "starttime" field in which I would like to store the timestamp that was set upon opening, since when a user logs off, the timestamp gets changed to the log off time.

Code:

Dim myQry As String
Dim sUserName As String
Dim sUserComputer As String
Dim currentVersion As Date

[code]....

The UserTimestamp in red is the field value of the first record in the table, not the usertimestamp in the user's record. How do I store the log on timestamp in the "starttime" field?

View 1 Replies View Related

Modules & VBA :: Copy Linked Table To Another Back End

Jan 12, 2015

I have the usual setup with a front and back end.

I want to copy three of my tables from the back end to another database (backup) at regular intervals. When using docmd.CopyObject and docmd.TransferDatabase it is the link that get copied (naturally) and not the table itself.

View 1 Replies View Related

Modules & VBA :: Macro To Copy Records From One Table To Another

Jun 22, 2015

I have two tables in my Access database, their fields are exactly the same (for now). One table is called Uncheched. The other one is called Checked. So what is need is a macro that takes selected records in table Unchecked and copies them to the end of table Checked. Actually CUTS from Unchecked and PASTES to the end of Checked table.

Sub MoveRecords()
DoCmd.RunCommand acCmdCut
DoCmd.OpenTable "tblChecked", acNormal, acEdit
DoCmd.GoToRecord , , acLast
DoCmd.RunCommand acCmdPaste
End Sub

View 13 Replies View Related

Modules & VBA :: Copy Table To A Password Protected Database

Dec 11, 2013

I'm using the DoCmd.CopyObject method to copy a table from my front end db to my back end. My back end db is password protected and it keeps prompting me for the password. Can I somehow send the password in code so that the user is not prompted?

View 8 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 :: 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

Modules & VBA :: INSERT ADO Recordset Into Current Database Table

Apr 8, 2015

Code:
Function Write_rstADO_to_CurrdB_Table()
'Assumes you have already setup a DSN to your Server
'Assumes YOURDESTINATIONTABLE is the same structure as your SERVER.TABLE
Dim cnnADO As ADODB.Connection
Dim wkspDAO As DAO.Workspace

[Code] ....

View 1 Replies View Related

Modules & VBA :: Rename Table - Append Current Date On The End

Jul 2, 2014

I am using access 2010. I need to rename a table when I import the a new table. But I can't get the docmd rename code to work. I also want to append the current date on the end i.e.

docmd.rename, "tblOldTable(Currentdate)", actable, "tblOldTable"

doesn't work.

View 10 Replies View Related

General :: Copy And Paste Records With Current Date

Sep 24, 2013

I have a database that is tracking donations for my organization. I have some members who donate the same amount every month. Is there away to copy the records and paste them with the current date in the "Date Paid" field, and do this "Update" once a month? As opposed to typing in 200 records each month? I would assume that I would have to run an update query which filters to just the members that pay each month, but the big question is how to copy and paste these records. I am using Access 2010, I have some VB ability, but not an expert by any stretch. My SQL is not strong at all either.

View 3 Replies View Related

Modules & VBA :: Copy Data From Excel Sheet To Access Table And Then Compare Two Tables

Dec 2, 2014

I have a form where when the user clicks on the browse button then excel workbook filepath gets stored in the textbox as below:

Code:
Private Sub CommandButton1_Click()
ChooseFile
End Sub
Sub ChooseFile()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)

[Code] .....

Please see attached the excel workbook. Everytime the user will select Excel workbook using Browse button. Now in that file , the first sheetname will always be "Summary". I want to perform the following steps:

1. So now I want VBA code to copy the data from columns "Withdrawn","Obsolete","Updated","LitRef" from Summary sheet to the Access table named tblSummary.

2. When the data gets copied in Access table then write So VBA code that will check if the data in field LitRef in table "tblSummary" is present in field "Reference" of Access table "tblliterature" . if its present then check in the tblSummary , which corresponding fields out of "Withdrawn","Obsolete" and "Updated" stores "Y" .
3. If "Withdrawn" field value is "Y" then change the status of corresponding record of tblliteraure to "Withdrawn"
4. If "Obsolete" field value is "Y" then change the status of corresponding record of tblliteraure to "Obsolete"
5. If "Updated" field value is "Y" then change the status of corresponding record of tblliteraure to "Updated" .

View 14 Replies View Related

Modules & VBA :: Copy Excel File Or A Table In Access To Specific Location On FTP Server

Jul 11, 2013

I need some simple code that will copy an Excel file or a table in Access to a specific location on an FTP server. I would think this would be a very simple task, but I have yet to find any sample code that is *simple*. I have seen lots of code that requires downloading this dll or that mda, but the examples don't work. There must be something built into MS Access 2010 that will allow a file to be uploaded to an FTP site.

All the variables are known:

The FTP location (it never changes)
The FTP Username and Password (they never change)
The destination folder on the FTP site (it never changes)
The File type (it never changes)
The File name (available from the form in Access from which this will be executed)

I can either produce an output file, then copy it to the FTP site, or I can export the table directly to the FTP site with the file name for that day.

This seems to be a very simple task with no simple solution. Currently I am using an FTP app to get the file to the FTP site, but I would like to automate this. The process that creates the output file is already automated, so I would just like to add this to the existing code as its own module.

I'm looking for a simple command on the idea of:

DoCmd.FTPFile, acExel, TableName, FTPFilePath, FTPFileName, Username, Password, acUpload

just made all that above up and none of it is a real function/command in VBA, but is just the kind of thing I'm looking for.

I would think that since I can download and XML file from an FTP site that it should be child's play to upload a simple file to an FTP site, but I can't figure it out.

View 8 Replies View Related

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 2 Replies View Related







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