Hi, I am very new to access, so please bear with me. I have an order entry
form with a combo box for customer ID. It displays the company name, but it
is the custID that is bound to the table. What I want to do, is double click
on this field to open up the customer maintenance form, so that the company
info can be modified (or new account added) and then return to the order
entry form with the new information. It is this last piece that I am having
a problem with.
On the double click event of the combo box, I open the customer maintenance
form .
gstrCallingForm = Me.Name
gstrFieldName = "cboDlvCustID"
stDocName = "frmCustomerMaintenance"
stLinkCriteria = "[CustID]=" & Me![cboDlvCustID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
On the close event of the customer maintenance form I have the following
If mstrCallingForm = "frmOrderHeader" Then
If mstrFieldName = "cboPUCustID" Then
Forms!frmOrderHeader.cboPUCustID.SetFocus
Forms!frmOrderHeader.cboPUCustID.Text = [Company]
End If
If mstrFieldName = "cboDlvCustID" Then
Forms!frmOrderHeader.cboDlvCustID.SetFocus
Forms!frmOrderHeader!cboDlvCustID.Text = [Company]
End If
This seems to work fine as long as I don’t have multiple accounts with the
same Company (which is the name). I really want to use CustID but when I
tried that instead of company I got a not in list error because it was
putting the account number in the combo box which displays the name.
I tried cboDLVCustID.ItemData(0) = [Custid] but I got errors on this too.
There must be a way to do this but I can’t seem to get the right keywords etc.
Any help would be truly appreciated.
Thanks

Signature
Beth
Sergey Poberezovskiy - 19 Jan 2006 00:18 GMT
try
Forms!frmOrderHeader!cboDlvCustID = [Company]
This will change the value of the combobox (and does not require setting the
focus).
HTH
> Hi, I am very new to access, so please bear with me. I have an order entry
> form with a combo box for customer ID. It displays the company name, but it
[quoted text clipped - 40 lines]
>
> Thanks
Bethh - 19 Jan 2006 12:48 GMT
Sergey, thank you for your response. That does change the combo box, but
that is the problem, sort of. Company is the name, not the unique id. So if
I have more than 1 company with the same name, it returns me the first one in
the list - not necessarily the one I had open in customer maintenance. I'm
sure I could get around this by using the custid in the combo box and just
displaying the name as a textbox but I was trying to conserve screen space
and the users don't really care about the ID #. Thanks anyway.

Signature
Beth
> try
>
[quoted text clipped - 49 lines]
> >
> > Thanks
Sergey Poberezovskiy - 20 Jan 2006 00:35 GMT
Bethh,
My bad - As long as you have your combobox's Bound to CompanyID and set the
combo value to an ID (not a name) you should be fine:
Forms!frmOrderHeader!cboDlvCustID = [Custid]
HTH
> Sergey, thank you for your response. That does change the combo box, but
> that is the problem, sort of. Company is the name, not the unique id. So if
[quoted text clipped - 57 lines]
> > >
> > > Thanks
Bethh - 20 Jan 2006 13:24 GMT
Yes, that would work, but I was trying to avoid dipalying both the name and
the ID. I guess I will just have to do it that way.
Thanks for your help.

Signature
Beth
> Bethh,
>
[quoted text clipped - 66 lines]
> > > >
> > > > Thanks
Sergey Poberezovskiy - 22 Jan 2006 23:03 GMT
Beth,
You just have to change the ColumnWidths property so that it hides the ID
column -something like:
myBox.ColumnWidths = "0cm;2cm;"
This will set the width of the first (ID) column to zero, and the last to
say, 2 cm.
> Yes, that would work, but I was trying to avoid dipalying both the name and
> the ID. I guess I will just have to do it that way.
[quoted text clipped - 70 lines]
> > > > >
> > > > > Thanks
Bethh - 23 Jan 2006 12:40 GMT
Sergey,
That's the way I have it set up now. So that it displays company but custid
is the bound field (not displayed) but if I set the combo box = custid I get
a not in list error. if I set it = company, it works. That's my problem.

Signature
Beth
> Beth,
>
[quoted text clipped - 79 lines]
> > > > > >
> > > > > > Thanks
Sergey Poberezovskiy - 23 Jan 2006 22:37 GMT
Beth,
Please ensure the following for your combobox:
- RowSource returns ID as one of the fields
- BoundColumn is set to the ID field ordinal (starting from 1 - not 0)
- ControlSource is not set or set to ID field
then if you set the combobox (not it's Text) to an ID it is bound to work -
it does not matter whether the id is visible or not.
HTH
> Sergey,
> That's the way I have it set up now. So that it displays company but custid
[quoted text clipped - 84 lines]
> > > > > > >
> > > > > > > Thanks
Bethh - 24 Jan 2006 12:57 GMT
Sergey,
Thank you so much for all your help and patience. I believe, I had it set
up like that but I have changed it so many times it's hard to know for sure.
Anyway, I got it working now although I'm not exactly sure what I changed to
make it work. Thanks so much for sticking with me.

Signature
Beth
> Beth,
>
[quoted text clipped - 96 lines]
> > > > > > > >
> > > > > > > > Thanks