Copying content of previous field

Valery

Registered User.
Local time
Today, 13:03
Joined
Jun 22, 2013
Messages
363
Hi all,

I would like the text from the previous field Invoice_Contact copied into the field Invoice_Contact of each new record created. I think I can use CTRL ' - but would like it done automatically if possible.

Field location:
Form = PatientUpdate - Subform = F_Invoice - Field = Invoice_Contact

The form and subform are linked through: Pat_ID
The subform is based on the table called Invoice with Invoice_ID as the primary key.

I tried several variations of this DLookup from examples I found on the web but the field comes out with "error" in it and its flashing! (scary!!)

Thank you! MUCH appreciated.
 
Perhaps a simple solution would be to set the Default Value property of the control in it's After UpDate event. Somthing like:
Me.ActiveControl.DefaultValue = Me.ActiveControl
The control would need to be edited once.
 
I will try it and see what it does when there is no previous record entered. But sounds great to me!

Thank you (again!)
 
Mmm... I put this coding - as is - in the on click event of the field. Even with a previous record entered and saved, it is returning: Run-time error 13 - type mismatch.

Just a text field.
 
Ok no errors but does nothing... even after I get out of the record, cursor back to my main form and note Ctrl ' does work... just tested in case
 
What happens if you type "Bob Fitz" in the control and then go to a new record
 
Nothing. This is what I have:

Private Sub Invoice_Contact_AfterUpdate()
Me.ActiveControl.DefaultValue = Me.ActiveControl
End Sub

Is there not a command for Ctrl apostrophe - where I could put in double click let's say...
 
Sorry. Code should be:
Me.ActiveControl.DefaultValue = "'" & Me.ActiveControl & "'"
 
It does not return an error but does not work. Simply does nothing - left the record, came back... nothing in that field. Others are there, filled out manually.

Mmm??!
 
What happens if you edit the data in the text box of any existing record, then go to a new record.
 
Same, tried that also, nothing. No error but no text "copied" either. Weird, no?
 
Have you checked that the code does actually fire by putting a breakpoint in the code or putting a line of code in to the procedure that opens a message box. Also check that the code is in the After Update event of the correct text box.
 
I don't know how to insert a "breaking point" but I have check and double checked - the code is in the right field, in the AfterUpdate event in the Properties.

Sorry it took so long to reply but looked up how to put a breaking point... tried a few things but nothing worked.
 
I don't know how to insert a "breaking point" but I have check and double checked - the code is in the right field, in the AfterUpdate event in the Properties.

Sorry it took so long to reply but looked up how to put a breaking point... tried a few things but nothing worked.
Did you try to put a line of code in the procedure to open a message box as I suggested in my last post.:(
With regards to "Breakpoints", I just googled "vba Breakpoint" and got loads of great sites that explain how to debug your code.:(
 

Users who are viewing this thread

Back
Top Bottom