Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 10th, 2005, 06:56 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: Warks, Warks, United Kingdom.
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
Reply With Quote
  #2 (permalink)  
Old February 11th, 2005, 06:07 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: , , United Kingdom.
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
Reply With Quote
  #3 (permalink)  
Old February 28th, 2005, 06:03 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: Warks, Warks, United Kingdom.
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
Reply With Quote
  #4 (permalink)  
Old March 3rd, 2005, 04:36 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: , , United Kingdom.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:34 PM.


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