C
Cameron Piper
For a general layout of my database as it pertains to
this question, see database layout below.
I am having trouble with a popup form that is not opening
to the right Record when opened. (form open code below)
If a client already has a phone number in the databse,
there is no problem. The form opens to that client's
phone number(s) and I am able to add, edit, and delete
them with no problems.
The problem that I am having is when I open a client
without a phone number, it will open to a blank form and
all seems well, but if I add a phone number in the
subform, it will assign it a clientID number of zero.
In the reading that I did on google today, I think that I
should be using the openargs command in the form open
event. Will someone please help me make sense of this.
The text that I tried to used in the open form event was:
Private Sub Form_Open(Cancel As Integer)
Dim strClientID As String
strClientID = Forms!frmClient.OpenArgs
End Sub
But it only returned an error for me. Please Help
Cameron Piper
(e-mail address removed)
Code to Open Form:
Private Sub Command200_Click()
On Error GoTo Err_Command200_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "fsubPhone"
stLinkCriteria = "[ClientID]=" & Me![ClientID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command200_Click:
Exit Sub
Err_Command200_Click:
MsgBox Err.Description
Resume Exit_Command200_Click
End Sub
Database Layout:
I am working on an access 2002 database on a microsoft
Office and Windows XP based machine.
There are two tables in my question:
1. tblPhones
PhoneID: Primary Key, Autonumber
ClientID: Linked to Primary Key in tblClient
Other Phone Number Fields (areacode, extension, notes,
etc.)
2. tblClient
ClientID: Primary Key, Autonumber
Other Client Fields (namefirst, namelast, occupation,
etc.)
There are two three forms in my question:
1. frmClient: Used to enter all sorts of information
about a client
Record Source: tblClient
2. fsubPhone: Is a popup form opened by a command button
on frmClient. It is simply a hosting form for a few misc
phone command buttons and a subform.
3. fsubPhoneContinuous: Is a subform nested in frmPhone.
Is a continuous view form used to add the actual phone
numbers themselves.
this question, see database layout below.
I am having trouble with a popup form that is not opening
to the right Record when opened. (form open code below)
If a client already has a phone number in the databse,
there is no problem. The form opens to that client's
phone number(s) and I am able to add, edit, and delete
them with no problems.
The problem that I am having is when I open a client
without a phone number, it will open to a blank form and
all seems well, but if I add a phone number in the
subform, it will assign it a clientID number of zero.
In the reading that I did on google today, I think that I
should be using the openargs command in the form open
event. Will someone please help me make sense of this.
The text that I tried to used in the open form event was:
Private Sub Form_Open(Cancel As Integer)
Dim strClientID As String
strClientID = Forms!frmClient.OpenArgs
End Sub
But it only returned an error for me. Please Help
Cameron Piper
(e-mail address removed)
Code to Open Form:
Private Sub Command200_Click()
On Error GoTo Err_Command200_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "fsubPhone"
stLinkCriteria = "[ClientID]=" & Me![ClientID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command200_Click:
Exit Sub
Err_Command200_Click:
MsgBox Err.Description
Resume Exit_Command200_Click
End Sub
Database Layout:
I am working on an access 2002 database on a microsoft
Office and Windows XP based machine.
There are two tables in my question:
1. tblPhones
PhoneID: Primary Key, Autonumber
ClientID: Linked to Primary Key in tblClient
Other Phone Number Fields (areacode, extension, notes,
etc.)
2. tblClient
ClientID: Primary Key, Autonumber
Other Client Fields (namefirst, namelast, occupation,
etc.)
There are two three forms in my question:
1. frmClient: Used to enter all sorts of information
about a client
Record Source: tblClient
2. fsubPhone: Is a popup form opened by a command button
on frmClient. It is simply a hosting form for a few misc
phone command buttons and a subform.
3. fsubPhoneContinuous: Is a subform nested in frmPhone.
Is a continuous view form used to add the actual phone
numbers themselves.