Results 1 to 2 of 2

Strange Error When Trying To Populate Access Form

  1. #1
    VSCurtis is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Dec 2014
    Posts
    65

    Strange Error When Trying To Populate Access Form

    Hi Guys,



    I've created a very simple data entry form with basic functions like Add Edit Delete Move First and such. I decided to add a method for searching for a specific record and displaying the record. The method I use is to select the search value from a combo box and then use FirdFirst to find the record and set the controls equal to their field values. I call the same code I use to display the data during regular move operations. However when I call the code under the search condition it produces error number 2115 The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Access from saving the data in the field. All fields are unbound controls as far as controls being bound to a field in the table but combo boxes and such are populated with data from their associated lookup tables. There is NO ValidationRule and nothing is happening in the BeforeUpdate event procedure.

    I could really use some help here. This error makes NO sense to me at all given that the same code works just fine during move operations. I've included all code below.

    Thanks In Advance

    Code:
    Private Sub cmbCards_Click()
    rs.FindFirst ("[Card Name] = '" & cmbCards.Text & "'")
    If Not rs.NoMatch Then
       GetCardData
    End If
    End Sub
    Code:
    Private Sub GetCardData()
    LoadCardFields
    LoadCardImage
    End Sub
    Code:
    Private Sub LoadCardFields()
    txtCardName.SetFocus
    If Not IsNull(rs("Card Name")) Then
       txtCardName.Text = rs("Card Name")
    Else
       txtCardName.Text = vbNullString
    End If
    If Not IsNull(rs("Category ID")) Then
       cmbCardCategories.Value = rs("Category ID")
    Else
       cmbCardCategories.Value = -1
    End If
    'If Not IsNull(rs("Card Type ID")) Then
    '   cmbCardType.Value = rs("Card Type ID")
    'Else
    '   cmbCardType.Value = -1
    'End If
    If Not IsNull(rs("Monster Type ID")) Then
       cmbMonsterType.Value = rs("Monster Type ID")
    Else
       cmbMonsterType.Value = -1
    End If
    CheckCardCategory
    End Sub
    Code:
    Private Sub LoadCardImage()
       imgCard.Picture = sPath & rs("File Name")
       
    End Sub
    Code:
    Private Sub CheckCardCategory()
    If cmbCardCategories.Value = "M" Then
       cmbMonsterType.Enabled = True
    Else
       cmbMonsterType.Enabled = False
    End If
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,598
    Shot in the dark, but try the after update event of the combo instead of the click event. Also, dont use the Text property.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Strange error
    By jecho_nl in forum Macros
    Replies: 4
    Last Post: 01-30-2017, 08:22 AM
  2. Damaged mdb 2010 file gives strange error message
    By sanchomosso in forum Access
    Replies: 2
    Last Post: 06-07-2015, 06:27 PM
  3. Strange behaviour of MS Access form
    By selvakumar.arc in forum Forms
    Replies: 2
    Last Post: 08-15-2013, 12:07 AM
  4. Replies: 2
    Last Post: 03-29-2011, 01:26 PM
  5. Replies: 6
    Last Post: 03-17-2010, 10:09 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
  •  
Tech Forums: Microsoft Office Forums