OpenArgs Question - Augh!

B

bunnyca

This has been driving me nuts for about a week now so I thought someone more
experienced might have the answer as although it's complex for me, the
newbie, it really is realtively simple.

Q: I am using Access 2000. I have a client database. I am making a search
form. The form is in dataview. It gets it's info. from a query that sorts the
info from the client table. The info consists of the contactfirstname,
contactlastname, clientID, nextactiondate, and case status.

When the user double clicks on a particular client's info. I would like for
the "Clients" form to open up to that client's information.

At this point, the "Client's" form opens but to the client's information.

Here is what I have so far for the ClientSearch Form:

Option Compare Database

Private Sub ViewClients()
On Error GoTo Err_ViewClients
DoCmd.OpenForm "Clients"

Exit_ViewClients:
Exit Sub

Err_ViewClients:
MsgBox Err.Description
Resume Exit_ViewClients
End Sub
Private Sub ClientID_DblClick(Cancel As Integer)
ViewClients
End Sub

Private Sub ContactLastName_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub
Private Sub ContactFirstName_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub
Private Sub NextActionDate_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub

Private Sub Case_Worker_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub

--------------------------------------------
and this is what I have for the "Clients" Form (only the portion that
pertains to the search)

Option Compare Database
Option Explicit
Dim cboOriginator As ComboBox

Private Sub Form_Open(Cancel As Integer)
If Not IsLoaded("ClientSearch") Then
MsgBox "Open the Projects form using the Projects button on the
Client Search form."
Cancel = True
End If
End Sub
Private Sub Form_Activate()
On Error GoTo Err_Form_Activate
Me.Requery

Exit_Form_Activate:
Exit Sub

Err_Form_Activate:
MsgBox Err.Description
Resume Exit_Form_Activate
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
On Error GoTo Err_Form_BeforeInsert
Me![ClientID] = Forms![ClientSearch]![ClientID]

Exit_Form_BeforeInsert:
Exit Sub

Err_Form_BeforeInsert:
MsgBox Err.Description
Resume Exit_Form_BeforeInsert
End Sub
Private Sub Form_Load()
If Me.OpenArgs = "GotoNew" And Not IsNull([ClientID]) Then
DoCmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
End If
End Sub
-----------------------------------------------------------

As you can probably tell I am doing this in piecework! Any help is greatly
appreciated!!!!

Thanx so much.
 
M

Minton M

This has been driving me nuts for about a week now so I thought someone more
experienced might have the answer as although it's complex for me, the
newbie, it really is realtively simple.

Q: I am using Access 2000. I have a client database. I am making a search
form. The form is in dataview. It gets it's info. from a query that sorts the
info from the client table. The info consists of the contactfirstname,
contactlastname, clientID, nextactiondate, and case status.

When the user double clicks on a particular client's info. I would like for
the "Clients" form to open up to that client's information.

At this point, the "Client's" form opens but to the client's information.

Here is what I have so far for the ClientSearch Form:

Option Compare Database

Private Sub ViewClients()
On Error GoTo Err_ViewClients
DoCmd.OpenForm "Clients"

Exit_ViewClients:
Exit Sub

Err_ViewClients:
MsgBox Err.Description
Resume Exit_ViewClients
End Sub
Private Sub ClientID_DblClick(Cancel As Integer)
ViewClients
End Sub

Private Sub ContactLastName_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub
Private Sub ContactFirstName_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub
Private Sub NextActionDate_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub

Private Sub Case_Worker_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub

--------------------------------------------
and this is what I have for the "Clients" Form (only the portion that
pertains to the search)

Option Compare Database
Option Explicit
Dim cboOriginator As ComboBox

Private Sub Form_Open(Cancel As Integer)
If Not IsLoaded("ClientSearch") Then
MsgBox "Open the Projects form using the Projects button on the
Client Search form."
Cancel = True
End If
End Sub
Private Sub Form_Activate()
On Error GoTo Err_Form_Activate
Me.Requery

Exit_Form_Activate:
Exit Sub

Err_Form_Activate:
MsgBox Err.Description
Resume Exit_Form_Activate
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
On Error GoTo Err_Form_BeforeInsert
Me![ClientID] = Forms![ClientSearch]![ClientID]

Exit_Form_BeforeInsert:
Exit Sub

Err_Form_BeforeInsert:
MsgBox Err.Description
Resume Exit_Form_BeforeInsert
End Sub
Private Sub Form_Load()
If Me.OpenArgs = "GotoNew" And Not IsNull([ClientID]) Then
DoCmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
End If
End Sub
-----------------------------------------------------------

As you can probably tell I am doing this in piecework! Any help is greatly
appreciated!!!!

Thanx so much.

You need to pass the client ID from the search form to the client form
using OpenArgs in DoCmd.OpenForm:

Sub OpenClients()
DoCmd.OpenForm "Clients", acNormal, , , acReadOnly, , lClientID
End Sub

Sub Form_Open(Cancel As Integer)
Dim lClientID As Long
' If OpenArgs property contains employee name, find
' corresponding employee record and display it on form. For
' example,if the OpenArgs property contains "Callahan",
' move to first "Callahan" record.
lClientID = Forms!Employees.OpenArgs
If lClientID > 0 Then
DoCmd.GoToControl "idClient"
DoCmd.FindRecord lClientID , , True, , True, , True
End If
End Sub

Hope this helps,
James
 
B

bunnyca

Hello Minton.

Would I supplement the code that you referred to on the "Clients" form or on
the "ClientSearch" form and would I leave the other coding on the search form
as it currently reads?

Sub OpenClients()
DoCmd.OpenForm "Clients", acNormal, , , acReadOnly, , lClientID
End Sub

Sub Form_Open(Cancel As Integer)
Dim lClientID As Long
' If OpenArgs property contains employee name, find
' corresponding employee record and display it on form. For
' example,if the OpenArgs property contains "Callahan",
' move to first "Callahan" record.
lClientID = Forms!Clients.OpenArgs
If lClientID > 0 Then
DoCmd.GoToControl "idClient"
DoCmd.FindRecord lClientID , , True, , True, , True
End If
End Sub


--
Have a great day!


Minton M said:
This has been driving me nuts for about a week now so I thought someone more
experienced might have the answer as although it's complex for me, the
newbie, it really is realtively simple.

Q: I am using Access 2000. I have a client database. I am making a search
form. The form is in dataview. It gets it's info. from a query that sorts the
info from the client table. The info consists of the contactfirstname,
contactlastname, clientID, nextactiondate, and case status.

When the user double clicks on a particular client's info. I would like for
the "Clients" form to open up to that client's information.

At this point, the "Client's" form opens but to the client's information.

Here is what I have so far for the ClientSearch Form:

Option Compare Database

Private Sub ViewClients()
On Error GoTo Err_ViewClients
DoCmd.OpenForm "Clients"

Exit_ViewClients:
Exit Sub

Err_ViewClients:
MsgBox Err.Description
Resume Exit_ViewClients
End Sub
Private Sub ClientID_DblClick(Cancel As Integer)
ViewClients
End Sub

Private Sub ContactLastName_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub
Private Sub ContactFirstName_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub
Private Sub NextActionDate_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub

Private Sub Case_Worker_DblClick(Cancel As Integer)
DoCmd.OpenForm "Clients"
End Sub

--------------------------------------------
and this is what I have for the "Clients" Form (only the portion that
pertains to the search)

Option Compare Database
Option Explicit
Dim cboOriginator As ComboBox

Private Sub Form_Open(Cancel As Integer)
If Not IsLoaded("ClientSearch") Then
MsgBox "Open the Projects form using the Projects button on the
Client Search form."
Cancel = True
End If
End Sub
Private Sub Form_Activate()
On Error GoTo Err_Form_Activate
Me.Requery

Exit_Form_Activate:
Exit Sub

Err_Form_Activate:
MsgBox Err.Description
Resume Exit_Form_Activate
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
On Error GoTo Err_Form_BeforeInsert
Me![ClientID] = Forms![ClientSearch]![ClientID]

Exit_Form_BeforeInsert:
Exit Sub

Err_Form_BeforeInsert:
MsgBox Err.Description
Resume Exit_Form_BeforeInsert
End Sub
Private Sub Form_Load()
If Me.OpenArgs = "GotoNew" And Not IsNull([ClientID]) Then
DoCmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
End If
End Sub
-----------------------------------------------------------

As you can probably tell I am doing this in piecework! Any help is greatly
appreciated!!!!

Thanx so much.

You need to pass the client ID from the search form to the client form
using OpenArgs in DoCmd.OpenForm:

Sub OpenClients()
DoCmd.OpenForm "Clients", acNormal, , , acReadOnly, , lClientID
End Sub

Sub Form_Open(Cancel As Integer)
Dim lClientID As Long
' If OpenArgs property contains employee name, find
' corresponding employee record and display it on form. For
' example,if the OpenArgs property contains "Callahan",
' move to first "Callahan" record.
lClientID = Forms!Employees.OpenArgs
If lClientID > 0 Then
DoCmd.GoToControl "idClient"
DoCmd.FindRecord lClientID , , True, , True, , True
End If
End Sub

Hope this helps,
James
 

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