Close Active Form

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

I have some code that opens a form named TimeCards and then copies data into
it and then I want it to close the active form from wher the data came from
which is named Customers.
What is wrong with my code ?

On Error GoTo Err_Command17_Click
Dim stDocName As String
Dim stlinkCriteria As String

stDocName = "TimeCards"
DoCmd.OpenForm stDocName, , , stlinkCriteria
Forms![TimeCards]![NameA] = Forms![Customers]![Customers]
Forms![TimeCards]![Address] = Forms![Customers]![Address]
Forms![TimeCards]![City] = Forms![Customers]![City]
Forms![TimeCards]![Phone] = Forms![Customers]![Phone]
DoCmd.Close , acForm

Exit_Command17_Click:
Exit Sub

Err_Command17_Click:
MsgBox Err.Description
Resume Exit_Command17_Click
 
Dave Elliott said:
I have some code that opens a form named TimeCards and then copies
data into it and then I want it to close the active form from wher
the data came from which is named Customers.
What is wrong with my code ?

On Error GoTo Err_Command17_Click
Dim stDocName As String
Dim stlinkCriteria As String

stDocName = "TimeCards"
DoCmd.OpenForm stDocName, , , stlinkCriteria
Forms![TimeCards]![NameA] = Forms![Customers]![Customers]
Forms![TimeCards]![Address] = Forms![Customers]![Address]
Forms![TimeCards]![City] = Forms![Customers]![City]
Forms![TimeCards]![Phone] = Forms![Customers]![Phone]
DoCmd.Close , acForm

Exit_Command17_Click:
Exit Sub

Err_Command17_Click:
MsgBox Err.Description
Resume Exit_Command17_Click

Instead of
DoCmd.Close , acForm

use

DoCmd.Close acForm, Me.Name
 
Thanks,

Dave

Dirk Goldgar said:
Dave Elliott said:
I have some code that opens a form named TimeCards and then copies
data into it and then I want it to close the active form from wher
the data came from which is named Customers.
What is wrong with my code ?

On Error GoTo Err_Command17_Click
Dim stDocName As String
Dim stlinkCriteria As String

stDocName = "TimeCards"
DoCmd.OpenForm stDocName, , , stlinkCriteria
Forms![TimeCards]![NameA] = Forms![Customers]![Customers]
Forms![TimeCards]![Address] = Forms![Customers]![Address]
Forms![TimeCards]![City] = Forms![Customers]![City]
Forms![TimeCards]![Phone] = Forms![Customers]![Phone]
DoCmd.Close , acForm

Exit_Command17_Click:
Exit Sub

Err_Command17_Click:
MsgBox Err.Description
Resume Exit_Command17_Click

Instead of
DoCmd.Close , acForm

use

DoCmd.Close acForm, Me.Name

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top