Update ID to another table

In my partial code below I am updateting two tables at the same time, What is 
the code to pass the new Autonumber from the one table rec2 to the other 
table rec?  This is how my relationship is setup 

 Also notice the Truck ID in rec statement, This is from a combobox, How can 
I get just the ID sent not the actual number? I have tried 
Me!CmbTruckNumber.ID or TruckID as the field is called, I have a code in 
place for the combobox to update new Truck number if not listed.


    
Set rec = dbLocal.OpenRecordset("LoadInfoTbl", dbOpenDynaset)
Set rec2 = dbLocal.OpenRecordset("EquationTbl", dbOpenDynaset)
    
    With rec2
        .AddNew
        !Exspense = Me!TxtExspense
        !PlantDiscount = Me!TxtPlantDiscount
        !PurchasePrice = Me!TxtBoughtPrice
        !HotPrice = Me!TxtHotPrice
        !HaulCost = Me!TxtHaulCost
        !Yield = Me!TxtYield
        .Update
        
    End With
    With rec
        .AddNew
        !BuyDate = Me!TxtDate
        !Weight = Me!TxtWeight
        !Mileage = Me!TxtMileage
        !Rate = Me!TxtRate
        !BuyPrice = Me!TxtBuyPrice
        !TruckID = Me!CmbTruckNumber
        .Update
    End With

Thank You
    
  
0
Utf
11/30/2009 10:27:02 PM
access.formscoding 7493 articles. 0 followers. Follow

1 Replies
776 Views

Similar Articles

[PageSpeed] 39

I'm not sure when teh autonumber is assigned. It may be available as soon as 
you add the first field info.
In that case
rec.othernumber = rec2.autonumberfield.
If that fails you will have to use a soevents and get it from teh last 
record.
Simply binding your tables to the form would do the same thing by using a 
subform that only showed a single record.
Your combobox would notmally return the ID of the record as opposed to some 
other value but I'm not sure I know exactly what you are asking.
Grizz wrote:
> In my partial code below I am updateting two tables at the same time,
> What is the code to pass the new Autonumber from the one table rec2
> to the other table rec?  This is how my relationship is setup
>
> Also notice the Truck ID in rec statement, This is from a combobox,
> How can I get just the ID sent not the actual number? I have tried
> Me!CmbTruckNumber.ID or TruckID as the field is called, I have a code
> in place for the combobox to update new Truck number if not listed.
>
>
>
> Set rec = dbLocal.OpenRecordset("LoadInfoTbl", dbOpenDynaset)
> Set rec2 = dbLocal.OpenRecordset("EquationTbl", dbOpenDynaset)
>
>    With rec2
>        .AddNew
>        !Exspense = Me!TxtExspense
>        !PlantDiscount = Me!TxtPlantDiscount
>        !PurchasePrice = Me!TxtBoughtPrice
>        !HotPrice = Me!TxtHotPrice
>        !HaulCost = Me!TxtHaulCost
>        !Yield = Me!TxtYield
>        .Update
>
>    End With
>    With rec
>        .AddNew
>        !BuyDate = Me!TxtDate
>        !Weight = Me!TxtWeight
>        !Mileage = Me!TxtMileage
>        !Rate = Me!TxtRate
>        !BuyPrice = Me!TxtBuyPrice
>        !TruckID = Me!CmbTruckNumber
>        .Update
>    End With
>
> Thank You 


0
Mike
12/2/2009 8:06:57 PM
Reply:

Similar Artilces:

Contact not fully updating
Has anyone come across this before The Contact entity is updated by clicking on the contact on the company screen . The update attribute is updated then Saved When you view that contact within a VIEW, the old email address still appears. So then if you use Workflow or indeed select the company record to send an email the old email address is recognised instead of the new email address? Any help would be appreciated Thanks KG Does it work for the installation user (i.e. the crm admin user?) If it does, than probably down to a crm\sql permissions issue. Run sql profiler to see wh...

Pivot Tables
....On one spreadsheet, I'm collating raw data each month about members of staff who use our company eLearning portal: name, subject, time spent. I've then created a Pivot Table on another sheet which fits the bill, except in one respect. I've added a comment in the employee name cell if they pass the course. When I refresh the Pivot Table monthly, it isn't in A-Z order (i.e. new employees are added to the bottom). If I re-sort using the A-Z button, any comments remain absolute instead of moving relatively with the employee name. Any way round this or am I updating the P...

Speciefie table and not cells to sum
Hi, I'm trying to make a summary in a specified tabell without have to specifie what start and end cell. So far I have done like this SUMMA.OMF(Januari!$C$4:$C$92;Januari!$A$4:$A$92;"=x") but I want something like this Summa.omf(Januari[#Allt] etc.... so that I can specifie column and tablename. I hope someone knows howe to do this. -- Best regards Mia Hi Mia, I do not re ognize which language version you using. try: SUMMA.OMF(Januari!$C:$C;Januari!$A:$A;"=x") HTH, Wouter Hi, Thank you so much for your help, it wo...

Why do pivot tables not read numbers that are copied and pasted
I am working with a Pivot Table whose information comes from a two columns of data that has been assembled from data copied and pasted from other sheets. Unless I retype all the data, it only shows zeros when sum is selected from field settings. I need a way to get it to sum without retyping or at least to know why it will not sum the numbers. Thanks Excel is seeing the numbers as text. There are some techniques here that you can use to convert the text to numbers, so they can be summed in the pivot table: http://www.contextures.com/xlDataEntry03.html B_4j wrote: > I am worki...

Chart update according to high to low ranking
I have a chart that updates using a total line; values change daily and update the totals; I would like the chart to display left to right/high to low and I cannot sort the total/sum line to cause the chart to display this way; is there a way I can do this? It is a column chart. Thank you! -- Marv Lusk Use an intermediate range for the chart source which links to the real data but uses large() to provide the sorting. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "MarvInBoise"...

2 different checkbook id's, but truly only 1 checkbook
2 different users are posting into "what they thought" was the same checkbook id, but actually is 2 different checkbooks. So I want to transfer all of the data from one of the checkbooks to the other checkbook, then inactivate that one. I thought there might be something in SQL to do this, but MS Support says no. There is lots of data in both, do you have any suggestions on how to get rid of one of the checkbooks and merge to the other checkbook? Thanks. -- cscheible There are quite a few complications to this request. My first question, which can change some of my other ...

remove (blank) from pivot table
I'd appreciate any hints on how to remove the (blank) in the body of pivot tables..so that the cell is indeed, blank (has no text) Thanks Jerry Ranch I fill my empty cells with a formula that looks empty: ="" Select your range edit|goto|special blanks type ="" and hit ctrl-enter to fill that range You could also use an apostrophe, but I like the formula--it's easy to see and it reminds me why it's there. Jerome Ranch wrote: > > I'd appreciate any hints on how to remove the (blank) in the body of > pivot tables..so that the cell is indeed, blan...

Unorthodox Pivot Table Chart
I have attached my pivot table chart and data. Has this happened t anyone? Does anyone know how to fix this? I have posted this proble verbally on this site before, but a picture is worth a thousand words I am referring to the 51068 and 52062 columns. Thanks for the help +------------------------------------------------------------------- |Filename: PT Problem.JPG |Download: http://www.excelforum.com/attachment.php?postid=2805 +------------------------------------------------------------------- -- Tycon2 ---------------------------------------...

Rep ID on POS reciept
Does anyone know how to add the Rep ID on the sales reciept? -- Microsoft Partner I know there is a Entry.SalesRep.Number variable that can be used. "Yaniv Zahavi" <yaniv@intermakers.com> wrote in message news:8F158FED-316A-4D98-94F2-B93D87B2ABC7@microsoft.com... > Does anyone know how to add the Rep ID on the sales reciept? > -- > Microsoft Partner Do you know where can I find information on how to integrate that? "root" wrote: > I know there is a Entry.SalesRep.Number variable that can be used. > > > > "Yaniv Zahavi" &...

Pivot table question #4
Hello all, I am working on a Excel data table. The 3 columns are year(i.e. 2011), dollar amount, purchase dollar amount. I have been asked to group by year in the following buckets. 0-2 years 2-3 years 3-5 years 5-10 years 10+ years I seem to be able to group by 2 year intervals, 3 year intervals etc, but cannot seem to group as I have been asked. That is 2 years, then 1 year, then 2 years, then 5 years. Any help would be greatly appreciated. Thank you! TimD On Feb 10, 7:36=A0pm, tdkooch <malor...@gmail.com> wrote: > Hello all, > I am working on a Excel data table. =A0The 3...

Event ID: 3092 public folders Replication Errors
Hi, Iam having a replication error in Exchange 2003/cluster. If I send e-mail to a public folder it gose to the following folder: In system manager > Administrative Groups > Utrecht (site name) > Mail (the vertiual server name) > Protocols > HTTP > Exchange Vertual Server > Exchange > Click with right mouse and go to "Browse" then I see the e-mails there. with other words: If a user sends an e-mail to a public folder it goes to the Exchange folder in the HTTP vertual server. In the Event viewer of the mail server I get these Events: Event ID: 3092 Source: E...

Writting ACCESS table to Excel
I am trying to write to Excel and have this code.. which fails at line Dim Rst1 As New ADODB.Recordset, saying "User definded type not defined" . Also after witrring I want to rename my template Any thoughts? Sub xl() Dim DXrptPath As String DXrptPath = "r:\temp\Resultsreportingworksheet.xls" '***Opening Report Template Dim myDB As Database Set myDB = CurrentDb Set ExcelWindow = CreateObject("excel.application") ExcelWindow.Visible = True ExcelWindow.Workbooks.Open (DXrptPath) Dim DXrpt As Workbook Set DXrpt = ActiveWorkbook DXrpt.A...

ComboBox_SubForms_Updating Tables
Hi, I have a form such that on the main form it has: Month GroupID (Combo) TransferAmt Transfer Cmd button On the SubForm which is linked by Month and GroupID Month - picks up from mainform GroupID(Combo) - picks up from mainform TransferInAmt - The TransferInAmt should be what is in the TransferAmt on the main Form. >From the Main Form: I should be able to enter a month, put in a group from GroupID and a TransferAmt - when I click on Transfer Cmd Button it should update the CentralLoc file such that Month, GroupID , TransferAmt Fields are updated. At the same time on the subform: Tr...

macro to calculate or make/update formula
i have the following in cell D2: "=IF(C2<C4,D4,IF(C2<C5,D5,IF(C2<C6,D6,IF(C2<C7,D7,IF(C2<C8,D8,D9)))))" basically, in C2 is a value; column B from row 4 down has the lower bracket and column C from row 4 down has the upper bracket; Column D will have another value that will calculate back into D2. ex: MIN MAX RESULT 0 100 28 101 200 25 201 300 22 301 18 and so forth..., if C2 has a value of 223, D2 would show 22. the problem is sometimes the min and max values will change and the amount of brackets will als...

KB971486 update results in BSOD during boot on Dell Latitude D630
Installation of patch for KB971486 via Windows update resulted in BSOD (0x0000007E) during boot in both normal mode and last known good configuration. Booting in safe mode also was not possible as the system hung with an empty pale blue background screen. The only possible resolution was booting from CD to access the recover console and run 'batch spuninst.txt' for the patch which did fix the problem although it's a rather painstaking process. System is a Dell Latitude D630, intel 965 graphics chipset, 2GB ram. Running XP Home SP2 with regular Windows updates prev...

Sum in Subform & Main Table #Name?- HELP!
I'm using Access 2003 and I have a subform within a subform and I keep getting #Name? Main Subform is "frmsubContractors" Other Subform is "frmsubContractors2Agree" and in the frmsubContractors2Agree I have a total currency field in the footer called "calcTotalAwardsContract" The control source of "calcTotalAwardsContract" =nz(Sum([fldawardamt]),0) which works great However when I refer to the "calcTotalAwardsContract" field in the main subform with a field named "calcTotalInitialAward" with a control source of =frm...

Counting dates in a pivot table
I am trying to make a pivot table together with a chart in which I count the number of events in a month. Basically I have a long list with dates of which I am creating a pivot table in which I am counting the number of dates per month, so far so good. However when there are no entries for a certain month the pivot table is skipping this month. For example when there are no May-dates it would look like this: Mar 25 Apr 96 Jun 64 etc. Is it possible to make a pivot table which would say: Mar 25 Apr 96 May 0 Jun 64 When making a graph this would prevent mis-interpretation when cert...

Do not calculate or update formula's during macro
Is there so code to keep formulas in a spreadsheet from updating? I have a macro that changes sheet names and location of some data but I do not want the formulas referring to those sheets to update. In other words, my formula may read ='Section 2'!A2-'Section 3'!A2 Part of my macro is to rename my sheets so 'Section 3" becomes "Section 2" and "Section 2" becomes "Section 1". After my macro, the formula ends up reading ='Section 1'!A2-'Section 2'!A2 I want to avoid that happening. I don't want my for...

Another Text Function problem
In case RD, Ken, or Barbara did not get my message, thanks for your help with the last text function problem. Your examples and explanations were very helpful! Here's another problem. Here is a list of imported codes: JMCC2C KAO2D JMCC2A JMCC2E RPT2A RPT2B RPT2C RPT2E PEC1C PEC1D The first few characters represent the description, the number (second from the end) represent a region, and the last number represents the manufacturer. The manufacturer column is the easy one. But I am trying to figure out how to extract the description code (which can vary between 1 to 4 characters, an...

Combo box value does not update in Excel 2007
I inserted a combo box form control in a cell and found problems with changing the value. Another cell on the worksheet contains a formula using the value in the combo box. When I selected a new value in the combo box and recalculated the formula it used the old value in the combo box rather than the new one. I noticed that when I used the arrow keys to navigate back to the cell containing the combo box the formula bar showed the old value, even though the combo box in the cell showed the new value. Am I doing something wrong, or is Excel not behaving as it should? bum...

Worksheet 260 should NOT update Quantities
A worksheet 260 should not update quantities and there should be another worksheet that does that. I have had clients run a 260 for several reason (add alias, change description, etc.) however because the 401 comes after the 260, everytime a 260 is run, it screws up the quantity amounts in the store. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Mic...

Table missing is ADOX that actually exists
I'm having a strange problem looping through toe ADOX.catalog object. I'm looking for a series of tables whcich I'm copying from another database. I refresh the catalog by deleteing the object as recreating it after copying the tables (which I've noticed is necessary). Six of the seven tables show up fine. The seventh doesn't isn't in the Tables collection (it's actually # 5 in the sequece of seven). The table DOES exists, and WAS copied successfully. I verified this when the debugger breaks by checking the tables. Anybody experienced this? Details: It&#...

Copying from data from another worksheet to exisiting.
Hi- Could someone tell me the way to copy a closed worksheet to the existing one. I have a macro in a template, and it gets kicked off every morning. I want to get the data from a another worksheet when it gets kicked off and then do the manipulation with that data.Could someone help!I would really appreciate it. Thanks jnair ** Posted via: http://www.ozgrid.com Excel Templates, Training, Add-ins & Business Software Galore! Free Excel Forum http://www.ozgrid.com/forum *** If the range doesn't change, maybe you could just use links: Open both workbooks. in the "receiving&quo...

Help with creating dynamic table & filtering
I have data that looks like this: WW_Yr OpenDays Sminor Smedium Scritical Sundefined WW01 14 1 0 0 0 WW01 1 0 1 0 0 WW02 15 1 0 0 0 WW02 129 0 0 1 0 WW03 17 0 0 0 0 WW04 13 1 0 0 0 etc. This data starts in cell A1 and goes across to column M and the number of rows can be different. So in the 1st column I can have 1 or more records with the same week # indicator. The other fields are numbers. The last 4 columns are basically true/false. There will only be a "1" in one of the fields. The 1st thing I want to do is to create a dynamic table based on this dat...

Copying toolbars from one PC to another
Is there a way to copy a customized Excel toolbar from one PC to another? tia, sh Shieber, Excel stores custom toolbars in a file called Excel.xlb. It is normally stored under: C:\Documents and Settings\UserName\Application Data\Microsoft\Excel ( \ XLSTART ) in Win2K or later, or C:\Program Files\Microsoft Office\Office\XLStart in Win98 or earlier. Find it and copy it to the target PC in the relevant folder. HTH, Nikos "Shieber" <shieber4@comcast.net> wrote in message news:%23ilGI5DLEHA.3852@TK2MSFTNGP10.phx.gbl... > Is there a way to copy a customized Excel toolba...