Windows 10: Access Database Problem Solved

Page 1 of 2 12 LastLast
  1.    17 Jan 2018 #1

    Access Database Problem


    I am developing an Access database for a local charity which teaches people to use the internet. One field is a tick box flagging that the user is a Member. There are other categories of user (User, Tenant, One to One) and the charity later required a separate field listing that status and allowing multiple entries into the field. This is done via a Combo Box set to allow multiple entries. Their requirements allow various possibilities of entering inconsistent data (e.g. Tick box says Member but the combo box field does not include Member) I wrote code to check for such inconsistencies. However with the multiple entry combo box code does not recognise the .Value of the combo box field so it can't check if Member is included. If the combo box is set to only allow one entry the same code works as required and can see what the field contains. I cannot find a solution to this. Does anyone recognise why?
      My ComputerSystem Spec


  2. Posts : 222
    Win10 Ver. 1809 Build 17763.`
       17 Jan 2018 #2

    Make a separate Access demo file that has just the form and code you are having trouble with and post it somewhere it can be downloaded.
      My ComputerSystem Spec

  3.    17 Jan 2018 #3

    Access dadabase problem


    It will be difficult to post as you suggest, partly but not completely as it would reveal real data. Instead I am posting the relevant code error. It is described as "runtime error 13, type mismatch"

    Private Sub cmdConsistency_Click()
    Dim Cancel As Integer
    Call Check59_Exit(Cancel)
    'Call cmbPersonType_Exit(Cancel)
    Call PersonTypeID_Exit(Cancel)
    'If Check59.Value = False And cmbPersonType.Value = 1 Then
    'MsgBox "PersonType value is " & PersonTypeID.Value
    If Check59.Value = False And PersonTypeID.Value = "Member" Then
    MsgBox "Person Type is set to member but Member tick box is not set"
    End If
    If Check59.Value = True And PersonTypeID.Value <> "Member" Then
    MsgBox "Member tick box is set but PersonType is not Member"
    End If
    End Sub

    The section in bold is the type mismatch. Exactly the same code with the same data works fine when the field PersonTypeID is a combobox where only one value can be entered to the field.
      My ComputerSystem Spec


  4. Posts : 222
    Win10 Ver. 1809 Build 17763.`
       17 Jan 2018 #4

    This looks like some sort of compiler quirk to me. Try this (just a guess):

    Private Sub cmdConsistency_Click()
    Dim Cancel As Integer, x as String
    Call Check59_Exit(Cancel)
    'Call cmbPersonType_Exit(Cancel)
    Call PersonTypeID_Exit(Cancel)
    'If Check59.Value = False And cmbPersonType.Value = 1 Then
    'MsgBox "PersonType value is " & PersonTypeID.Valuex=PersonTypeID.Value
    x=PersonTypeID.Value
    If Check59.Value = False And x = "Member" Then
    MsgBox "Person Type is set to member but Member tick box is not set"
    End If
    If Check59.Value = True And x <> "Member" Then
    MsgBox "Member tick box is set but PersonType is not Member"
    End If
    End Sub
      My ComputerSystem Spec

  5.    18 Jan 2018 #5

    Access Database Problem


    Thanks for that. Still the same problem. This time Debug flags the line x = PersonTypeID.Value as the type mismatch
      My ComputerSystem Spec

  6.    18 Jan 2018 #6

    As it says 'Type Mismatch', it looks as though you need:

    If Check59.Value = False And cstr$(PersonTypeID.Value) = "Member" Then

    Also, if PersonTypeID is a control on a form, why do need to put .Value, as Value should be the default?

    This is what I would use:If Check59.Value = False And cstr$(Me![PersonTypeID]) = "Member" Then
      My ComputerSystem Spec

  7.    18 Jan 2018 #7

    access database problem


    I should mention that using a query returns the value of PersonTypeID.Value (but only shows the first entry in the case where multiple entries have been selected). So the query recognises PersonTypeID. Value but Visual Basic does not for a multiple entry combo Box (but does for a single entry Combo box)
      My ComputerSystem Spec

  8.    18 Jan 2018 #8

    access database problem


    Tried both of nbcaldon's suggestions. Both still give the same type mismatch. Thanks for the ideas.
      My ComputerSystem Spec

  9.    18 Jan 2018 #9

    Maybe the value is null. Try testing for this first:

    if isnull(Me![PersonTypeID]) then stop

    and then check what is going on in the code.
      My ComputerSystem Spec

  10.    18 Jan 2018 #10

    access database problem


    No that's not it !
      My ComputerSystem Spec


 
Page 1 of 2 12 LastLast

Related Threads
Solved Win 10 Update Database Corruption in Windows Updates and Activation
When I run the Windows Update Troubleshooter it says the Windows Update Database is corrupted. How can I fix this? Advice would be appreciated.
Hi I have error when to connect visual studio and database , I tried two windows 10 and 7 but does not solve the problem, its after I search for Google and YouTube could not find , two time reinstall Windows 10, 7, same problem 114189
Greetings. I dont know how to stop Lotus Notes aplication error. When i open .nsf file get the message : You are not authorized to the database for user's local mail file Ple​ase advice me something for Lotus Notes fix. Regards
I recently upgraded to W10 and now when I try to change a form in Access 2010 DB It errors and has to close. The error is : Faulting module path: C:\PROGRA~2\COMMON~1\MICROS~1\VBA\VBA7\VBE7.DLL. If I undo the change then all is fine. There was a...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 07:02.
Find Us