Results 1 to 5 of 5
  1. #1
    Jan11811 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    2

    List Box Problem

    Hi All,



    I have a list box on one of my forms that looks up customer names. It is linked to tblCustomer. It did work before but I am thinking that I have messed up the VB somehow when you click on it now nothing happens where before it would have brought the customer details into the form. UPDATE** And my exit form button has stopped working Arrrrgh here is the whole of the VB code

    Code:
    Option Compare Database
    
    
    
    Private Sub lstCustomer_AfterUpdate()
    Me.Filter = ""
    Me.FilterOn = False
    Me.Filter = "CustomerID=" & Forms!frmCustomer!lstCustomer
    Me.FilterOn = True
    End Sub
    
    Private Sub Postcode_AfterUpdate()
    Me.Refresh
    End Sub
    
    '------------------------------------------------------------
    ' cmdAddRecord_Click
    '
    '------------------------------------------------------------
    Private Sub cmdAddRecord_Click()
    On Error GoTo cmdAddRecord_Click_Err
    
        On Error Resume Next
        DoCmd.GoToRecord , "", acNewRec
        If (MacroError <> 0) Then
            Beep
            MsgBox MacroError.Description, vbOKOnly, ""
        End If
    
    
    cmdAddRecord_Click_Exit:
        Exit Sub
    
    cmdAddRecord_Click_Err:
        MsgBox Error$
        Resume cmdAddRecord_Click_Exit
    
    End Sub
    
    
    '------------------------------------------------------------
    ' cmdExitForm_Click
    '
    '------------------------------------------------------------
    Private Sub cmdExitForm_Click()
    On Error GoTo cmdExitForm_Click_Err
    
        DoCmd.Close , ""
    
    
    cmdExitForm_Click_Exit:
        Exit Sub
    
    cmdExitForm_Click_Err:
        MsgBox Error$
        Resume cmdExitForm_Click_Exit
    
    End Sub
    Not sure if I need to provide more info?? Would be grateful for any help!!

    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Is any code running? If not, make sure you've got the db in a Trusted Location, or explicitly enabled code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    okerix is offline Novice
    Windows 7 Access 2007
    Join Date
    Apr 2010
    Posts
    3
    I always use recordset so don't mess much with the Filter function. I have had my vb code corrupt before though. What you do is copy and cut all your code from the vb then save so its saving a blank vb page. Then reopen the code for that form and paste you code back in. It has worked for me numerous times, hope it works for you.

  4. #4
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    try putting in Option Excplicit up top to ensure that you arent using variables that you havnt created, or using them with mixed datatypes. When you say it used to run well but now has stopped, it leads me to believe that something that one of those variables is referencing has changed in either format,datatype,whatever and it is screwing up the code. Option Explicit is a great way to catch stuff like that.

  5. #5
    Jan11811 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    2
    Thanks for all the replies I saved a blank VB page and then pasted the code and it worked again. Thanks for the tips, don't ya just love all the helpful ppl online ... awesome!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 03-25-2010, 12:31 PM
  2. Not in list problem
    By DanW in forum Forms
    Replies: 24
    Last Post: 11-18-2009, 03:45 PM
  3. query problem i have a problem wi
    By maxx3 in forum Queries
    Replies: 0
    Last Post: 06-29-2009, 02:29 AM
  4. About value in list box?
    By viccop in forum Forms
    Replies: 0
    Last Post: 04-08-2009, 08:05 PM
  5. List box to populate other list boxes
    By Nathan in forum Forms
    Replies: 0
    Last Post: 03-03-2009, 07:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums