Select Copied Record

treva26

Registered User.
Local time
Yesterday, 21:05
Joined
Sep 19, 2007
Messages
113
I am using the following code to copy a record, and open it in another form.

I then want to clear some of the fields etc but when I do it does it to the original record in the form I have already closed!

It says "The expression you entered refers to an object that is already closed or doesnt exist"

I have tried
Code:
DoCmd.RunCommand (acCmdSelectRecord)
but that doesnt seem to work.

Here is my code (its in the SEARCH form, after copying it opens the ECL form):

Code:
Private Sub CreateSub_Click()
'On Error GoTo errorhandling1

'remember original QDBID
Dim OGquote1 As Long, OGquote2 As String
OGquote1 = Me.QuoteDBID

' Open in ECL
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "ECL FORM 2"
stLinkCriteria = "[QuoteDBID]=" & Me![QDBID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
    
' Copy to a new record
DoCmd.RunCommand (acCmdSelectRecord)
DoCmd.RunCommand (acCmdCopy)
DoCmd.GoToRecord acDataForm, "ECL FORM 2", acNewRec
DoCmd.RunCommand (acCmdPaste)

DoCmd.Close acForm, "Search Form"

' DELETE ALL UNWANTED FIELDS!
[Full Quote Num] = Null
[Suffix] = Null
[Parent Quote] = Null
' etc...
 
Last edited:
First thing, I'm not sure why you are using the copy and paste when you can just refer to the item in question. But, the DoCmd syntax doesn't require the parentheses.

DoCmd.RunCommand acCmdCopy

would be correct and you don't need any parens.

Since it looks like your other form is still open, after you get to the record you want, you can just use

Forms!Your2ndFormNameHere.YourtextBoxNameHere = Me.YourTextBoxNameOnTheFirstForm
 
Yes, thank you for pointing that out.

I was doing it in a very retarded way..

:o
 

Users who are viewing this thread

Back
Top Bottom