Data transfer from one form to another

harrop11

Registered User.
Local time
Yesterday, 23:35
Joined
Jun 5, 2009
Messages
11
Could somebody please shed some light on a problem i'm having.
Bassically i want to create a record in a form which only has fields from the one table in it. The problem i'm having is now once this record has been created i want to be able to copy the primary key which i have just created to another form in the place of a foreign key.

I've tried the wizards and the Me..... suggestions plastered all over the web which just don't seem to copy the data required.
 
Here is a copy of the database.

I want to add a new record to the frm_newvehicle and then transfer the registration number of that new entry to the frm_fulldetail where a new incident can be created.

Anyones input would be great.
 

Attachments

I've tried the wizards and the Me..... suggestions plastered all over the web which just don't seem to copy the data required.
First of all, do you know what the keyword ME actually is?

from Bob Larson's website glossary said:
This is a programming shortcut which lets the programmer refer to the current CLASS object. Most of the time, in Access, you would be referring to a form or report using this. It can also apply to custom classes as well, but is less prevalent unless custom classes are being used.
Let's say you have a form named "frmMain" and you have a text box there called "txtEntry" and you wanted to refer to that text box in code. A fully-qualified reference would be Forms!frmMain.txtEntry but you could also refer to it using the shortcut (as long as the code is ON frmMain): Me.txtEntry
So, the big question is which event have you tried to do this on?

First of all the record needs to be saved -

So issuing a

If Me.Dirty Then Me.Dirty = False

will save the record. And then the other form has to be open. If it is then you can use:

Forms!YourOtherFormName.TextBox1NameHere = Me.YourTextBox1EquivalentFromTheFirstFormHere

etc.
 
As you will nkow know i dont really pretend to know anything i'm what i'm talking about but i did know that the Me keyword was a shortcut to the current table.

I have been trying these on the onclick event of the button.

I have tried the format you have suggested and many other combinations which were more than likely wrong but all with the same outcome.

Private Sub Command5_Click()
If Me.Dirty Then Me.Dirty = False
Forms!frm_fulldetail.Registration_No = Me.Registration_No
End Sub

I tried putting these codes into the code builder and i have tried using the macro builder to open a form with a specific field(also tried the code in here).
Both ways save the new entry to the table but just will not produce the data in the second form. I also tried this using 2 forms with basic data from 2 of the tables to no avail.

Sorry to be a pain but it must be something silly i'm doing wrong as everyone says more or less the same thing although it refuses to work for me.
 
I think i might have found what may be causing me some problems. I entered the following into the code builder in the on click event part:

Private Sub Command9_Click()
MsgBox "testing again"
End Sub

When i click the button it looks like it's trying to do something as it sort of sticks for a milisecond be doing absolutly nothing.
Could there be something stoping this from running or am i putting this in the wrong place?
 
Which version of Access are you using (including Service Pack)?
 
Microsoft office access 2007 (12.0.6211.1000) SP1 MSO (12.0.6213.1000)
 
Told you it was something stupid.
This is one of those time when you feel like a complete nugget.

Thank you very much, i'll now have another go. It's not like i've spent much time on it . . . .. . . . . . .
 

Users who are viewing this thread

Back
Top Bottom