Help Needed!! - Issue with an unbound combo box

J

J. B.

Hey all,

I am trying to accomplish opening 2 forms at the same time (One form is data
entry form for Calls and the other form contains a contact list box). The
way it is setup is that the data entry form called frmDataEntryCall would be
open and when the user selects a Customer from the combo box (named CustID)
on frmDataEntryCall the second form, frmContactList, would open having the
same Customer in the unbound combobox; which would produce the list of
contacts in the list box. I have code attached to the AfterUpdate Event
combo
box on the frmDataEntry. When I select a Customer on the frmDataEntryCall
form I receive the message: "Enter parameter value for Customers"
Customers is the unbound combo box.
The frmContactList works perfect by itself. I have even watched (Stoped
during runtime) the code and the variable stLinkCriteria (as seen below) has
the value of "Customers=3" (Assuming I selected the third customer in CustID
combo box)

Here is the code I have:

Private Sub CustID_AfterUpdate()
Me!ContactID.Requery
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmContactList"

stLinkCriteria = "[Customers]=" & Me![CustID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

I hope I have provided enough information. Sorry for being so long. Any
help would be greatly appreciated.

Thanks in advance,

J. B.
 
J

Jeff Boyce

Have you looked into using a main form/subform construction? The main form
would be where you select a customer, via a combo box. The subform would be
the contacts related to the selected customer.
 
G

Graham Mandeno

Hi J.B.

What is the name of the field in the recordsource of frmContactList that
contains the CustomerID?

Your line:
stLinkCriteria = "[Customers]=" & Me![CustID]
suggests that its name is "Customers", but I think that is unlikely, as it
is only the ID of a single customer.

Change the "[Customers]=" part to "[CustomerID]=" (or whatever the name is
of the corresponding field)
 
J

J. B.

Thanks you for your post. The name of the field in the recordsource of the
frmContactList that contains CustID is Customers. I tried what you
suggested but nothing record was transfered to the frmContactList.

After I posted last night, I placed a break in the code at the line
Docmd.OpenForm stDocName, , , stCriteria and the vaule for stCriteria was
the CustID from the frmDataEntryCall. After stopping the code I looked at
the Customers field on the frmContactList and on the Filer property was the
same value that showed as the stCriteria during the break. I tried to open
the frmContactList with that value in the Filter property and nothing
populated. This makes me entertain the thought of attacking this problem
from a different way. I was wondering since Customers on frmContactList is
an unbound combo box do I have to open a recordsetclone and use the
FindFirst method for looking for the record.

Thanks so much for you time,

J. B.


Graham Mandeno said:
Hi J.B.

What is the name of the field in the recordsource of frmContactList that
contains the CustomerID?

Your line:
stLinkCriteria = "[Customers]=" & Me![CustID]
suggests that its name is "Customers", but I think that is unlikely, as it
is only the ID of a single customer.

Change the "[Customers]=" part to "[CustomerID]=" (or whatever the name is
of the corresponding field)
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


J. B. said:
Hey all,

I am trying to accomplish opening 2 forms at the same time (One form is data
entry form for Calls and the other form contains a contact list box). The
way it is setup is that the data entry form called frmDataEntryCall
would
be
open and when the user selects a Customer from the combo box (named CustID)
on frmDataEntryCall the second form, frmContactList, would open having the
same Customer in the unbound combobox; which would produce the list of
contacts in the list box. I have code attached to the AfterUpdate Event
combo
box on the frmDataEntry. When I select a Customer on the frmDataEntryCall
form I receive the message: "Enter parameter value for Customers"
Customers is the unbound combo box.
The frmContactList works perfect by itself. I have even watched (Stoped
during runtime) the code and the variable stLinkCriteria (as seen below) has
the value of "Customers=3" (Assuming I selected the third customer in CustID
combo box)

Here is the code I have:

Private Sub CustID_AfterUpdate()
Me!ContactID.Requery
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmContactList"

stLinkCriteria = "[Customers]=" & Me![CustID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

I hope I have provided enough information. Sorry for being so long. Any
help would be greatly appreciated.

Thanks in advance,

J. B.
 
J

J. B.

Thanks for the reply. I do not have any subforms on either frmDataEntryCall
or frmContactList. When breaking the code, the value that is in the
stCriteria variable is the correct CustID value. I was wondering what other
ways of attacking this issue would be. I have even tried using a Macro, but
I was unsuccessful with that as well.

Thank you for you time,

J. B.
 
J

J. B.

Graham,

Just wanted to make sure you go my first reply to you. I guess I didn't
sent the reply to the group. If you didn't receive it let me know and I
will send again.

Thanks again for you time,

J. B.

Graham Mandeno said:
Hi J.B.

What is the name of the field in the recordsource of frmContactList that
contains the CustomerID?

Your line:
stLinkCriteria = "[Customers]=" & Me![CustID]
suggests that its name is "Customers", but I think that is unlikely, as it
is only the ID of a single customer.

Change the "[Customers]=" part to "[CustomerID]=" (or whatever the name is
of the corresponding field)
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


J. B. said:
Hey all,

I am trying to accomplish opening 2 forms at the same time (One form is data
entry form for Calls and the other form contains a contact list box). The
way it is setup is that the data entry form called frmDataEntryCall
would
be
open and when the user selects a Customer from the combo box (named CustID)
on frmDataEntryCall the second form, frmContactList, would open having the
same Customer in the unbound combobox; which would produce the list of
contacts in the list box. I have code attached to the AfterUpdate Event
combo
box on the frmDataEntry. When I select a Customer on the frmDataEntryCall
form I receive the message: "Enter parameter value for Customers"
Customers is the unbound combo box.
The frmContactList works perfect by itself. I have even watched (Stoped
during runtime) the code and the variable stLinkCriteria (as seen below) has
the value of "Customers=3" (Assuming I selected the third customer in CustID
combo box)

Here is the code I have:

Private Sub CustID_AfterUpdate()
Me!ContactID.Requery
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmContactList"

stLinkCriteria = "[Customers]=" & Me![CustID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

I hope I have provided enough information. Sorry for being so long. Any
help would be greatly appreciated.

Thanks in advance,

J. B.
 
G

Graham Mandeno

Hi J.B.

The way you are doing this is fine - it should be easy to fix.

The problem you describe is *exactly* what I would expect if the
RecordSource of the form you are opening does not include a field names
"Customers". Are you *sure* that "Customers" isn't the *name* of the
RecordSource, rather than a *field* in the RecordSource.

I suspect from what you say that the name of the *field* is actually
"CustID", and if this is the case then your criteria string should be:
stLinkCriteria = "[CustID]=" & Me![CustID]

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

J. B. said:
Thanks you for your post. The name of the field in the recordsource of the
frmContactList that contains CustID is Customers. I tried what you
suggested but nothing record was transfered to the frmContactList.

After I posted last night, I placed a break in the code at the line
Docmd.OpenForm stDocName, , , stCriteria and the vaule for stCriteria was
the CustID from the frmDataEntryCall. After stopping the code I looked at
the Customers field on the frmContactList and on the Filer property was the
same value that showed as the stCriteria during the break. I tried to open
the frmContactList with that value in the Filter property and nothing
populated. This makes me entertain the thought of attacking this problem
from a different way. I was wondering since Customers on frmContactList is
an unbound combo box do I have to open a recordsetclone and use the
FindFirst method for looking for the record.

Thanks so much for you time,

J. B.


Graham Mandeno said:
Hi J.B.

What is the name of the field in the recordsource of frmContactList that
contains the CustomerID?

Your line:
stLinkCriteria = "[Customers]=" & Me![CustID]
suggests that its name is "Customers", but I think that is unlikely, as it
is only the ID of a single customer.

Change the "[Customers]=" part to "[CustomerID]=" (or whatever the name is
of the corresponding field)
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


J. B. said:
Hey all,

I am trying to accomplish opening 2 forms at the same time (One form
is
data
entry form for Calls and the other form contains a contact list box). The
way it is setup is that the data entry form called frmDataEntryCall
would
be
open and when the user selects a Customer from the combo box (named CustID)
on frmDataEntryCall the second form, frmContactList, would open having the
same Customer in the unbound combobox; which would produce the list of
contacts in the list box. I have code attached to the AfterUpdate Event
combo
box on the frmDataEntry. When I select a Customer on the frmDataEntryCall
form I receive the message: "Enter parameter value for Customers"
Customers is the unbound combo box.
The frmContactList works perfect by itself. I have even watched (Stoped
during runtime) the code and the variable stLinkCriteria (as seen
below)
has
the value of "Customers=3" (Assuming I selected the third customer in CustID
combo box)

Here is the code I have:

Private Sub CustID_AfterUpdate()
Me!ContactID.Requery
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmContactList"

stLinkCriteria = "[Customers]=" & Me![CustID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

I hope I have provided enough information. Sorry for being so long. Any
help would be greatly appreciated.

Thanks in advance,

J. B.
 

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