[AccessD] Requery on setting row source or record source

Max Wanadoo max.wanadoo at gmail.com
Wed Dec 12 15:25:23 CST 2007


acDataErrAdded Doesn't display a message to the user but enables you to add
the entry to the combo box list in the NotInList event procedure. After the
entry is added, Microsoft Access updates the list by requerying the combo
box. 

Microsoft Access then rechecks the string against the combo box list, and
saves the value in the NewData argument in the field the combo box is bound
to. If the string is not in the list, then Microsoft Access displays an
error message. 

Private Sub Colors_NotInList(NewData As String, _
        Response As Integer)
    Dim ctl As Control
    
    ' Return Control object that points to combo box.
    Set ctl = Me!Colors
    ' Prompt user to verify they wish to add new value.
    If MsgBox("Value is not in list. Add it?", _
         vbOKCancel) = vbOK Then
        ' Set Response argument to indicate that data
        ' is being added.
        Response = acDataErrAdded
        ' Add string in NewData argument to row source.
        ctl.RowSource = ctl.RowSource & ";" & NewData
    Else
    ' If user chooses Cancel, suppress error message
    ' and undo changes.
        Response = acDataErrContinue
        ctl.Undo
    End If
End Sub
    

Regards
Max
(From the help page 'NOTINLIST')

 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust
Sent: Wednesday, December 12, 2007 9:02 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Requery on setting row source or record source

Just remember, if you are using a NotInList routine to add items to the
Combobox rowsource, you will need to requery. 

Charlotte

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at
Beach Access Software
Sent: Wednesday, December 12, 2007 11:39 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Requery on setting row source or record source

Thanks Charlotte.  Commenting out all them extraneous requeries now.

Rocky





 	
	

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust
Sent: Wednesday, December 12, 2007 10:42 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Requery on setting row source or record source

If you set the source through code, you shouldn't need to requery.  You need
to requery when the values in the current list change.

Charlotte Foust 


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list