Making record in one from equal record in another form

bloody_football

Registered User.
Local time
Tomorrow, 09:11
Joined
Sep 8, 2004
Messages
70
Making record in one form equal record in another form

A) In one form I have acceptance numbers which I wish to copy across to another record in another form (no I don't want to simply link them).
The code I am using is
Code:
Me.ReleaseNo = FormFrom.ReleaseAcceptance where Me.ID=FormFrom.QuoteID
I know this code is totally wrong but I am only new to access.

B) Another question, how do I change a record?
If I want 'Me.Accept' changed from '9' to 'AC9' (yes the number will always be the same), what is the code for it?
 
Last edited:
In answer to question B, it's pretty easy:

Accept = "AC9"

Now for question A. You have Form1 refering to data in Table1. Then, you have Form2 refering to data in Table2. Assuming the following:

Form2 opens as a result of a function on Form1 (ie, press button).
Form2 ALWAYS contains specific data relating to what is CURRENTLY displayed in Form1.
Form2 can NEVER display data for a record other than what is CURRENTLY being displayed in Form1.

To reference the first form from the second, use Forms!<formname>!<control>
So your code would look like this:

Code:
ReleaseNo = Forms!Form1!ReleaseAcceptance

Replace 'Form1' with the name of your first form.

HTH
 
Okay well I screwed up asking those questions :o

A) When I click on a button in my form (which is linked to 'table1') I want an automatic number created in another table (which I'll call 'table2'), then I want this number pulled back into table1 (table1 is not to create this number).

I'll have to re-word question B here as well - If 'acceptNo' is equal to 9 then how do I get the value of 'accept' to equal 'AC9', i.e the value of 'accept' is the same as the value of 'acceptNo' but with the value of 'AC' in front of it; the number value will change but it will always be 'AC' to be added.

Sorry for the confusion.

James
 
Last edited:
For B, do the following:
Code:
accept = "AC" & acceptNo
Put that code wherever you need it; I imagine on the 'lost focus' event of acceptNo.


For question A, you're going to be getting into setting recordsets.
Try the following:

Code:
Dim db, recordlist

set db = CurrentDB
set recordlist = db.openrecordset("table2")
With recordlist 
    .AddNew
    [COLOR=Orange]!field2 [/COLOR] = "Insert some sort of information into some field somewhere in table2 to make the new record stick"
    [COLOR=Blue]form1field1[/COLOR] = [COLOR=Orange]!keyfield[/COLOR]
    .Update
End With
Blue text refers to fields on form1, orange text refers to fields on table2.

This code will open table2, add a new record, then pull a field out of the new record back into your current form.

HTH
 

Users who are viewing this thread

Back
Top Bottom