Close Active Form

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
 
D

Dirk Goldgar

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
 
D

Dave Elliott

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top