 |
| 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
|
|
|
|

April 24th, 2005, 02:07 PM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

April 25th, 2005, 08:42 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Change the limit to list property.
Why do you want to allow data entry from this combo box?
mmcdonal
|
|

April 25th, 2005, 03:20 PM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

April 26th, 2005, 06:20 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
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
|
|

April 26th, 2005, 06:31 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
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
|
|
 |