My Assistant
![]() ![]() |
|
|
Mar 27 2012, 07:06 AM
Post
#1
|
|
|
UtterAccess Addict Posts: 237 |
Hi UA,
I have a form (loadhaulbav) that enters data into a table (tblload). In order to streamline data captunring I want to add a button or checkbox to populate certain fields from the previous record. I have started with a select case option on the checkmark: What I am having a hard time with is howto use the dlookup for the table and field for the last record enterd. CODE Private Sub chkreloadstep1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Select Case Me.chkreloadstep1.Value Case Is = True MsgBox "CASE TRUE" Case Is = False MsgBox "CASE FALSE" End Select End Sub Thank you for your time and help, Bongazi |
|
|
|
Mar 27 2012, 07:40 AM
Post
#2
|
|
|
UtterAccess Ruler Posts: 1,090 |
check this previous thread Module To Carry Values Over From Previous Form Entry., Office 2010
This post has been edited by arnelgp: Mar 27 2012, 07:41 AM |
|
|
|
Mar 27 2012, 07:56 AM
Post
#3
|
|
|
UtterAccess VIP Posts: 2,479 From: Downeast Maine |
Here is a way to duplicate the record in the main form along with any subform records. You could just leave out the part of the code that deals with the subform records:
http://allenbrowne.com/ser-57.html Essentially it would go something like this (in a command button Click event, for instance): CODE With Me.RecordsetClone .AddNew 'Add the fields that need to be the same in the new record. These are sample fields, so change the names as needed. !CustomerID = Me.CustomerID !EmployeeID = Me.EmployeeID !OrderDate = Date 'etc for other fields. .Update 'Display the new duplicate. Me.Bookmark = .LastModified End With There are other ways to go about this. For instance, the link shows INSERT SQL for adding the subform records. The same general approach could be used to add the main form records. The command button wizard can set up code to duplicate a record. However, in Access 2003 (and in 2000, I think) this uses DoMenuItem commands, and duplicates the entire record. It is possible to use acCmdSelectRecord, acCmdCopy, and acCmdPasteAppend in succession to accomplish copying the entire record, but I think you will be glad, eventually if not right away, to have more control than that method allows. |
|
|
|
Mar 27 2012, 08:15 AM
Post
#4
|
|
|
UtterAccess Addict Posts: 237 |
check this previous thread Module To Carry Values Over From Previous Form Entry., Office 2010 Hi arnelgp, thank you for that - I should have mentioned that I am running access 2010. Also the fields on the form are combo boxes that are being populated with data from different tables :-) I have implemented that code & Module but I get an compile error on the BeforeInsert Code: "Expected variable or procedure, not module" here: Call CarryOver(Me, strMsg) CODE Private Sub Form_BeforeInsert(Cancel As Integer) Dim strMsg As String Call CarryOver(Me, strMsg) If strMsg <> vbNullString Then MsgBox strMsg, vbInformation End If End Sub Thank you, Bongazi This post has been edited by Bongazi: Mar 27 2012, 08:49 AM |
|
|
|
Mar 27 2012, 10:52 AM
Post
#5
|
|
|
UtterAccess Addict Posts: 237 |
Hi arnelgp,
I have copied the code from the attached .zip you amended - and it works beautifully !! Thank you again for your time and help. Regards, Bongazi |
|
|
|
Mar 27 2012, 10:55 AM
Post
#6
|
|
|
UtterAccess Addict Posts: 237 |
Hi BruceM,
thank you for that, - I am already achieving what I need to do with arnelgp`s code.... I have not yet tried your code... seeing that the other alternative works good. Thank you again for your help! Kind regards, Bongazi |
|
|
|
Mar 27 2012, 11:53 AM
Post
#7
|
|
|
UtterAccess Ruler Posts: 1,090 |
Been out for a while.
You're welcome Bongazi. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 20th June 2013 - 06:07 AM |