Senin, 17 Juli 2017

Re: [MS_AccessPros] Adding items to a listbox

 

Here's an example of a NotInList procedure:


Private Sub RoomType_NotInList(NewData As String, Response As Integer)
Dim strName As String, strWhere As String
    
    ' User typed in a room type that's not in the list
    strName = NewData
    ' Build the verification search string
    strWhere = "[RoomType] = '" & strName & "'"
        
    ' Verify that they want to add the new Room Type
    If vbYes = MsgBox("Room Type " & NewData & " is not defined. " & _
        "Do you want to add this Room Type?", vbYesNo + vbQuestion + vbDefaultButton2, _
            gstrAppTitle) Then
        ' Open the add a Room Type form and pass it the new value
        DoCmd.OpenForm "frmRoomTypesAdd", DataMode:=acFormAdd, WindowMode:=acDialog, _
            OpenArgs:=strName
        ' Code will wait until "add" form closes - now verify that it got added!
        If IsNull(DLookup("RoomType", "tlkpRoomTypes", strWhere)) Then
            ' Ooops
            MsgBox "You failed to add a Room Type that matched what you entered.  " & _
                "Please try again.", vbInformation, gstrAppTitle
            ' Tell Access we handled the error, but cancel the update
            Response = acDataErrContinue
        Else
            ' Tell Access new data was added
            Response = acDataErrAdded
        End If
    Else
        ' Don't want to add what they typed - show standard error message
        Response = acDataErrDisplay
    End If
End Sub

The form it opens lets the user verify what they want to add and save it.  You could instead simply execute an INSERT SQL statement to directly add the value to the table of the underlying Row Source.
 
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Jul 17, 2017, at 5:36 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



They as multiple cabinet names:

Executive
Finance
Development
IT

Or whatever they want for Cabinet names.


With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Anyone who claimed that old age had brought them patience was either lying or senile."   








On Mon Jul 17 2017 07:37:17 GMT-0500 (Central Daylight Time), John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:


What is it you want to display in this list?


John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Jul 17, 2017, at 2:27 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



I suppose it would. Do you have an example of it. I just wanted the users to see their entries as they went along.


With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Anyone who claimed that old age had brought them patience was either lying or senile."   








On Sun Jul 16 2017 13:45:43 GMT-0500 (Central Daylight Time), John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:


Nope.


Would a combo box do?  You can type in that and handle any "new" entries in NotInList.

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Jul 16, 2017, at 8:44 PM, dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



is there a way to set a list box to accept manual entries?


Thank you 

Art Lorenzini

Sioux Falls, Sd










__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar