Results 1 to 8 of 8
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: a2 to a2002 coding problem (a2002)

    I can't get a complete idea of what's happening from the information you provided, so I just have some general remarks:

    1. What does the loose "DoCmd.OpenForm" do in lblList_Click?
    2. You might build in a check and exit the procedure if required data are missing.
    3. Many VBA programmers use a naming convention with three-character prefixes, such as "frm" for Form in "frmResponses". The prefix "lbl" is commonly used for a label, so "lblList" for a command button is confusing. For a command button, "cmd" is used, or "btn".

    You probably have code in the On Open or On Load event of frmResponses; perhaps it would be possible to say more if you posted that code.

  2. #2
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    a2 to a2002 coding problem (a2002)

    <P ID="edit" class=small>(Edited by ppem on 22-Jul-03 10:16. )</P>I'm working with a database that was originally created in Access2. I was able to update to Access2002 but in doing so I have apparently caused a problem in one of the forms. I've included a graphic showing the form itself, if that is helpful.

    This form has a check box (LmtList) on it that indicated that the answer to a question is restricted to a list and clicking it opens a form (frmResponses) for entering the list choices. There is also a command button (lblList) that opens that same form. I've included the code for both below.

    Private Sub lblList_Click()
    Me![QstnLvl3].SetFocus
    DoCmd.OpenForm "frmResponses", , , "[SrvQstnID] = " & Str(SrvQstnID), , A_DIALOG, Str(SrvQstnID)
    End Sub

    Private Sub LmtLst_AfterUpdate()
    If LmtLst Then
    DoCmd.OpenForm "frmResponses", , , "[SrvQstnID] = " & Str(SrvQstnID), , A_DIALOG, Str(SrvQstnID)
    End If
    End Sub

    Private Sub LmtLst_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
    Case 76, 108
    DoCmd.OpenForm "frmResponses", , , "[SrvQstnID] = " & Str(SrvQstnID), , A_DIALOG, Str(SrvQstnID)
    End Select
    End Sub

    The problem is
    1) The main form is not requiring so you get a "You could not add or change a record because related record is required in tblSrvQstns." when you exit frmResponses
    2) While no problems entering the responses for question 1 and 2 (provided I closed and reopened the main form before entering those responses), when I clicked on the command button for question 3 it opened the response list for question 1
    3) Clicking on the command button for a question you have already entered responses for yields a blank form, not the responses you already entered.

    Can anyone see from looking at the code where the problem is and suggest a solution?

    Elizabeth
    Attached Images Attached Images

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: a2 to a2002 coding problem (a2002)

    Elizabeth,

    I don't understand. Perhaps something got lost somewhere, but frmResponses doesn't do anything - when the user clicks Exit, the form just closes. It doesn't matter which reply the user selected. What's the purpose?

  4. #4
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: a2 to a2002 coding problem (a2002)

    Thanks for taking a shot at this.

    The loose "DoCmd.OpenForm" was me experimenting to find the current equivalent to A_DIALOG and then neglecting to remove the command line completely. It's gone now. The lblList was indeed a raised label with an on click event and not a command button.

    The On Load code for frmResponses is
    Private Sub Form_Load()
    If Len(Me.OpenArgs & "") > 0 Then
    Me![SrvQstnID].DefaultValue = Me.OpenArgs
    End If
    End Sub

    I thought it might help if you could see the setup in context so I've converted the db to A97 and zipped it to get it small enough to post and attached it here. Clicking "Enter survey questions and response options" on the opening form takes you to frmSurveys which includes sfrmQuestions. Clicking the List control on sfrmQuestions opens frmResponses.

    Please let me know if there is anything I can do to make this easier to analyze. I appreciate your assistance and don
    Attached Files Attached Files

  5. #5
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: a2 to a2002 coding problem (a2002)

    I'm sorry I'm not explaining this more clearly. Bare with me if this is repetitive...Here's what's suppose to happen:

    a) On frmSurvey you name and describe the survey.
    [img]/forums/images/smilies/cool.gif[/img] In sfrmQuestions (on frmSurvey) you enter the question number, the question and, if it's a forced choice selection, you check the box and/or click the "List" control.
    c) Either action one should open frmResponses (based on tlkpQstnLst). If the question does not already have responses entered a blank form should open. If you have already entered the response list for that question, the form should display a list of those responses.

    What's actually happening are the problems above, i.e. after entering the responses for the question in frmResponses when you attempt to close the form you get a "You could not add or change a record because related record is required in tblSrvQstns." And, when you close and reopen the frmSurveys to solve that problem and return to the question you were working on, clicking "List" may get a blank form or you might get the response list for another question in error.

    Something is amiss with the DoCmd.OpenForm filtering process on the List control (and the check box also?) but I'm not experienced enough to identify the problem. The responses entered on frmResponses are getting entered and associated correctly with the questions in tblRspndntsRspns and displaying correctly when entering respondents survey answers in frmSurveyResponses.

    Hope this closes the gap. If it doesn't maybe the convertion to 97 was problematic. If that's the case and you'd like to see the 2002 version, I'd be more than happy to have you take a look at it. It does exceed the 100K limit tho.

    Thanks for hanging in there,
    Elizabeth

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: a2 to a2002 coding problem (a2002)

    OK, that clarifies things. I thought it was a survey form; instead, it's a form to design surveys.

    Here is a solution to the "You can not add or change a record" problem: in each of the three routines that open frmResponses, insert the following lines immediately above DoCmd.OpenForm:

    If IsNull(Me.SrvQstnID) Then Exit Sub
    If Me.Dirty Then RuncCommand acCmdSaveRecord

    The first line checks if you have started entering a question and gets out if you haven't.
    The second line checks if the record has been modified, and if so, saves it.

    I'll look into your other questions.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: a2 to a2002 coding problem (a2002)

    The problem of the wrong responses coming up probably only occurs if you clcik the command button, not when you click the check box. The reason for this is a peculiarity of continuous forms: there is actually only one command button on the subform, even if you see several instances of it, because the command button is not bound to the data. Clicking the command button doesn't make the record it is in the active record. You can verify this by clicking ina text box on one record, then clicking the command button in another record; you will see that the blinking insertion point is still in the original record. So you get the responses for another question than you expected. I don't think that there is a remedy for this; you must either train your users to click in a text box on the correct record before clicking the command button, or avoid the use of the command button entirely.

  8. #8
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: a2 to a2002 coding problem (a2002)

    Hans,

    Thanks for the code and the information. These problems had been a source of enormous frustration for quite some time. Code worked like a charm and I elected to put instructions to the user to click on the record to ensure it was the active record prior to clicking on the List button in the footer of the form. Whew!! Glad that's over.

    Much appreciation,
    Elizabeth

Posting Permissions

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