Open Form with Current Record

P

Pasadena-D

Hello,

I have a user form that when the user clicks the ok button I want it to open
another form based on the same record number. I can make this happen using
the Access Macro as follows:
Form Name: frmTask_Complete
View: Form
Filter Name:
Where Condition: [Task_ID]=[Forms]![frmTask_List]![Task List Subform].[Form]!
[Task_ID]
Data Mode:
Window Mode: Normal

I want to use VB Code instead of the Access Macro, since I have other
controls I want to run and Access Code is very limited, but I cannot get my
VB Code to open the frmTask_Complete with the current record (Task_ID).
Here's the VBA Code I'm using:

DoCmd.OpenForm "frmTask_Complete", acNormal, , [Task_ID] = [Forms]!
[frmTask_List]![Task List Subform].[Form]![Task_ID], acFormEdit

Please help! I have spend hours and hours on this with no success.
 
R

ruralguy via AccessMonster.com

Have you tried converting your macro to code? What version of Access are you
using?

Pasadena-D said:
Hello,

I have a user form that when the user clicks the ok button I want it to open
another form based on the same record number. I can make this happen using
the Access Macro as follows:
Form Name: frmTask_Complete
View: Form
Filter Name:
Where Condition: [Task_ID]=[Forms]![frmTask_List]![Task List Subform].[Form]!
[Task_ID]
Data Mode:
Window Mode: Normal

I want to use VB Code instead of the Access Macro, since I have other
controls I want to run and Access Code is very limited, but I cannot get my
VB Code to open the frmTask_Complete with the current record (Task_ID).
Here's the VBA Code I'm using:

DoCmd.OpenForm "frmTask_Complete", acNormal, , [Task_ID] = [Forms]!
[frmTask_List]![Task List Subform].[Form]![Task_ID], acFormEdit

Please help! I have spend hours and hours on this with no success.
 
F

fredg

Hello,

I have a user form that when the user clicks the ok button I want it to open
another form based on the same record number. I can make this happen using
the Access Macro as follows:
Form Name: frmTask_Complete
View: Form
Filter Name:
Where Condition: [Task_ID]=[Forms]![frmTask_List]![Task List Subform].[Form]!
[Task_ID]
Data Mode:
Window Mode: Normal

I want to use VB Code instead of the Access Macro, since I have other
controls I want to run and Access Code is very limited, but I cannot get my
VB Code to open the frmTask_Complete with the current record (Task_ID).
Here's the VBA Code I'm using:

DoCmd.OpenForm "frmTask_Complete", acNormal, , [Task_ID] = [Forms]!
[frmTask_List]![Task List Subform].[Form]![Task_ID], acFormEdit

Please help! I have spend hours and hours on this with no success.

The Where clause argument of the OpenForm method needs to be a string
(enclosed within quotes).

If [Task_ID] is a Number datatype, then use:

DoCmd.OpenForm "frmTask_Complete", acNormal, , "[Task_ID] = " &
[Forms]![frmTask_List]![Task List Subform].[Form]![Task_ID],
acFormEdit

If, however, [Task_ID] is a Text datatype, then:

DoCmd.OpenForm "frmTask_Complete", acNormal, , "[Task_ID] = '" &
[Forms]![frmTask_List]![Task List Subform].[Form]![Task_ID] & "'",
acFormEdit
 
R

ruralguy via AccessMonster.com

Open the macro in design mode and then File>SaveAs>Module

Pasadena-D said:
I'm using Access 2003. How can i convert the macro to code?
Have you tried converting your macro to code? What version of Access are you
using?
[quoted text clipped - 4 lines]
 
P

Pasadena-D via AccessMonster.com

Cool...didn't know I could do that....this helps alot...Thanks for your help!
Open the macro in design mode and then File>SaveAs>Module
I'm using Access 2003. How can i convert the macro to code?
[quoted text clipped - 3 lines]
 
P

Pasadena-D via AccessMonster.com

fredg,

this worked....thanks for your help!
[quoted text clipped - 18 lines]
Please help! I have spend hours and hours on this with no success.

The Where clause argument of the OpenForm method needs to be a string
(enclosed within quotes).

If [Task_ID] is a Number datatype, then use:

DoCmd.OpenForm "frmTask_Complete", acNormal, , "[Task_ID] = " &
[Forms]![frmTask_List]![Task List Subform].[Form]![Task_ID],
acFormEdit

If, however, [Task_ID] is a Text datatype, then:

DoCmd.OpenForm "frmTask_Complete", acNormal, , "[Task_ID] = '" &
[Forms]![frmTask_List]![Task List Subform].[Form]![Task_ID] & "'",
acFormEdit
 

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