Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2005, 06:56 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 137
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multi Functioning Combo Boxes / Probs

I am currently developing a relational Access 2000 database application for a local charity. The database consists of a number of reports and forms. The database also uses VBA and Macros for more complex functionality. Which is where I have become a little stuck.

I have a form that allows users to boh view or add records to a given table using NEXT RECORD, ADD and DELETE BUTTONS. What I would like to do is have a combo box that enables users to select a given data attribute from a list during data entry, while also act a view field when the form is just being used just to view per record in the table. I am having a bit of a mental block and not really sure how to start? is this a simple thing to do? or do i need to use VBA?

Can somebody please help?



Gaz
__________________
Gaz
 
Old February 11th, 2005, 06:07 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Gaz,

You could create one combo and one text box. The combo box is shown when in dataentry or new record whilst the text box is shown for existing records, non data entry mode.

Use the forms OnCurrent event to check the PK field of the recordset. If it isnull then show the combo box, else show the text box.

Private Sub Form_Current()
  cboValues.visible = IsNull(me![PrimaryKey])
  txtValue.visible = Not IsNull(me![PrimaryKey])
End Sub

hth

Jon
 
Old February 28th, 2005, 06:03 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 137
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the tip that worked a treat. However, because the Primary Key is auto created - what I decided to do was check for another value is null when the user goes to add a record. Like so:

Private Sub Form_Current()
   Staff_ProjectCombo.Visible = IsNull(Me![Staff_Forename])
   Staff_Servicetxtbox.Visible = Not IsNull(Me![Staff_Forename])
End Sub

The combo box used creates a drop down list associated with another table. The final thing I want to achieve is, on selecting the save button when in NEW RECORD mode - how can I tell access to insert the select value in the combo box with the value in the associated table?

As at the moment when I go to save the RECORD and then view it - the value is 1 rather than the selected text value?

Could this be soemthing to do with my formatting of fields? or am I missing something?

Gaz
 
Old March 3rd, 2005, 04:36 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It Sounds like you need to set the column propertites of the cbo. the first column in your row source should be your Key value, the second column should be the data you want displayed. You can then set the properties of the cbo like so: ColumnCount = 2, ColumnWidths = 0cm;4cm, BoundColumn = 1.

This will then hide the numeric 'Key' value and just show the second column but the Key value is still bound to the underlying field.

Hth,

Jon





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-Select List Boxes and Calculations flrzeus BOOK: Expert One-on-One Access Application Development 0 December 5th, 2005 10:43 AM
3 combo boxes ttkt Beginning PHP 0 July 2nd, 2005 02:20 PM
Multi-Column Combo Boxes twsinc Access 1 September 22nd, 2004 12:14 PM
Combo Boxes tjs206 VS.NET 2002/2003 7 November 7th, 2003 04:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.