Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 April 24th, 2005, 02:07 PM
Registered User
 
Join Date: Apr 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default data access page - combobox

I'm a newbie and am trying to set the properties for a combo box on a data access page so that I can enter data as well as select from a list. I used the wizard to create the combo box. Currently, no data entry is allowed. I can only select from the list.

Can anyone help me?
Thanks,

ausir
 
Old April 25th, 2005, 08:42 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Change the limit to list property.

Why do you want to allow data entry from this combo box?

mmcdonal
 
Old April 25th, 2005, 03:20 PM
Registered User
 
Join Date: Apr 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thx for responding.

What "limit" are you referring to? When I list Element Properties - All, I do not find a "list" property, nor do I find a "limit" property to change. Should I go into script and insert either of these?

I'm trying to learn how to create an object that can accept data entry as well as accept data chosen via a list. In my particular scenario, the user can select from a standard set of text values (I want them available via the list), but numeric values are also valid, in which case, might be easier to key in.


ausir
 
Old April 26th, 2005, 06:20 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, you want to leave the Limit To List property set to Yes (on the Data tab of the combo box properties dialog box.) This is automatically set to Yes when you create the combo box with a wizard.

Then on the Combo Box's OnNotInList event, you need to add code that creates the record from the combo box's input.

If we knew what record you wanted to create, we could help you with that, too.


mmcdonal
 
Old April 26th, 2005, 06:31 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This is the sort of code you need to do data entry from your combo box. Put this code on the combo box's Not In List event:

(This code allows the user to add the data using the combo box, and then opens a second form to allow them to add additional data to complete the record.

'=====
Private Sub YourComboBox_NotInList(NewData As String, Response As Integer)

    Dim strsql As String, x As Integer
    Dim LinkCriteria As String

    x = MsgBox("Do you want to add this value to the list?", vbYesNo)

    If x = vbYes Then
        strsql = "Insert Into tblYourTable ([YourComboFieldName]) values ('" & NewData & "')"
        'MsgBox strsql
        CurrentDb.Execute strsql, dbFailOnError
        LinkCriteria = "[YourComboFieldName] = '" & Me!YourComboBox.Text & "'"
        DoCmd.OpenForm "YourSecondForm", , , LinkCriteria

        Response = acDataErrAdded
    Else
        Response = acDataErrContinue
    End If
End Sub
'=====

HTH


mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Access: Data Access Page sevp95 Access VBA 0 July 14th, 2008 11:07 AM
access data from another page rocksbhavesh ASP.NET 1.0 and 1.1 Professional 5 March 26th, 2007 08:18 AM
how to dispaly data in combobox from access? [email protected] VB.NET 2002/2003 Basics 4 October 30th, 2006 09:11 AM
Data Access Page Teqlump Access 9 November 1st, 2004 11:36 PM
Data access page access problem :) kev_79 Access 0 September 4th, 2003 04:02 PM





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