Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

Trying to return data to a combo box field from a different form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bethh - 18 Jan 2006 20:33 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.