+ Reply to Thread
Results 1 to 28 of 28

Userform Selecting listbox items erroneously

Hybrid View

  1. #1
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Userform Selecting listbox items erroneously

    This is the code thats ran immediately before opening the form in question.

    When a user clicks FAIL in one of the 8 questions, the Question Number and Answer theyve provided is passed to the following Sub eg
    Call Record_Answer("3","Fail")

    Private Sub Record_Answer(TheQuestion, TheAnswer)
    Dim SQLOut(15) As Variant
        'Delete any existing answers
        SQLOut(1) = "DELETE tblAnswers.CaseID, tblAnswers.Q_No FROM tblAnswers WHERE (((tblAnswers.[CaseID])=" & currCaseID & ") AND ((tblAnswers.[Q_No])= '" & TheQuestion & "'));"
        'add any new ones
        SQLOut(2) = "INSERT INTO tblAnswers ( CaseID, Q_No, Answer, Delay, Other ) SELECT " & currCaseID & ", '" & TheQuestion & "', '" & TheAnswer & "', " & TheDelay & ", '" & strOtherReason & "';"
        SQLOut(3) = "DELETE CaseID FROM tblFails WHERE ((tblFails.CaseID = " & currCaseID & ") AND (tblFails.Question = " & TheQuestion & "));"
        Call InsertArrayload(SQLOut, 4)
    'if Its a Fail then set some indicators and open the Failures form
    If (TheAnswer = "Fail") Then
            strOtherReason = ""
            TheDelay = 0
            intFailCall = 1
            strQstn = TheQuestion
            frmFail.Show
    Else
    'otherwise everything is cool and we can just update the Answers indicator to show this as Pass or NA
        Mid(AllQuestionsComplete, TheQuestion, 1) = Left(TheAnswer, 1)
    End If
    
    End Sub
    basically, it
    1. Deletes any records in the tblAnswers table (which contains a number of fields including the "Pass", "Fail","NA" status of the question)
    2. Deletes any records in tblFails table for that case and question.
    Inserts a new record in tblAnswers with the relevant answer, the answers for tblFails will then be INSERTed when the Save button is clicked on the form

    If its a FAIL then it resets a couple of indicators that may be used later on and opens the frmFail form (the one I have a problem with)


    I know what you're saying about Global Variables and would agree however I inherited this system at the point of going into user testing and although Im willing to do it, would involve a lot of rewriting to ensure its passing the variables here there and everywhere when required.

    I'll give the new Instance a go but surely, if it was something like that (or the Global variables) then it would affect all users? Thats the bit thats got me most confused how its only 3 users and alwys the same questions in each users case.
    Last edited by pjwhitfield; 05-21-2015 at 11:08 AM.
    If someone has helped you then please add to their Reputation

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Colour items in Userform Listbox
    By Lukael in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2014, 02:44 PM
  2. [SOLVED] Add Selected Items From One ListBox to Another ListBox on UserForm
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2014, 06:53 PM
  3. [SOLVED] Type Mismatch when selecting items from a listbox
    By Tayque_J_Holmes in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-07-2012, 04:46 PM
  4. selecting multiple listbox items based on test in range
    By kuraitori in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2009, 04:32 PM
  5. Selecting multiple items on Listbox
    By Rahul_Uk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-20-2006, 12:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1