Results 1 to 9 of 9
  1. #1
    nika.duncan is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    36

    Form not displaying data correctly when scrolling through

    Good day All


    Need some serious help trying my best to learn as much as possible. Hope you will be able to help again.

    I am working with two forms frmManager and frmMMeasures where based on selection from the combo box of frmManager of the department, position and staff member frmMMeasures is loaded where MUserLoginID and MPositionName is populated based on selection from frmManager. This is what I use to populate the MUserLoginID field for the control source " =[Forms]![frmManagers]![cboStaff] ".

    My problem is when I go to the next record on the form those two fields do not change from what was picked up from the form frmManager.

    I don't know how to ensure that the correct data is displayed.


    Please any help will be appreciated.
    Nika

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Not understanding. Need more info. Is this a form/subform arrangement? The controls are on which form? Is cboStaff a bound control?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    If your Manager form is controlling/filtering those values on the subform, then the values SHOULD NOT CHANGE when you go to another record. If you want them to change, then you probably need to use a recordset and repositioning rather than a filter... but I'd have to know more about your application to give specific advice.

  4. #4
    nika.duncan is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    36
    I have attached the db for you to have a look at it. Let me explain how it works. I have a login form - frmLogin1 which based on who logs in opens a specific form frmManager, frmSupervisor or frmStaff. I have only worked on the frmManager form - to select the staff to be evaluated. Then frmMMeasure opens base on selection from frmManager. The frmMMeasure opens to enter the data for each staff. The frmMMeasure has a subform frmSubMeasure where the areas for evaluation are entered. The problem lies here the fields in the main form frmMMeasure does not change when I go from record to record and if I add a record yes it is updated in table but I would have to scroll through to find it and even then the data displayed on the main form is not correct.

    I hope I was able to explained clearly, I am presently learning and any help is welcomed.

    Nika
    Attached Files Attached Files

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The frmMMeasures opens to all records in tblMeasure. The frmMMeasures textbox referencing cboStaff on frmManagers is meaningless and misleading. Bind MUserLoginID textbox to the field.

    If you want frmMMeasures to open with only those records for the user/manager logged in, then filter the dataset. Create a textbox on frmManagers and populate it with the userID from the login form. Then open frmMMeasures with:

    DoCmd.OpenForm "frmMMeasures", acNormal, , "MUserLoginID='" & Me.tbxUserID & "'", acNormal

    tblMeasure is not saving the UserLoginID, it is saving the UserSName.

    Why isn't UserID the primary/foreign key?

    There is a circular relationship between tblDepartment, tblPosition, tblUser. Department should not be in both tblUser and tblPosition.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    nika.duncan is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    36
    Thanks for all the help so far. I need some more guidance as to how to pass the fields from the frmManager to frmMMeasures. I have attached the database for you to see the changes that I have made in terms of the relationship and the forms.

    Please any help will be appreciated.

    Regards,
    Nika
    Attached Files Attached Files

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    tblMeasure records do not have values in MUserLoginID field. Makes it hard to filter the records by user.

    Is form tblMeasure no longer needed?

    Suggestion for code behind frmLogin1:

    Private Sub cmdExit_Click()
    DoCmd.OpenForm "frmManager", , , "MUserLoginID=" & Me.txtUserID
    DoCmd.Close acForm, "frmLogin1"
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    nika.duncan is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    36
    Hi
    I hope I am explaining clearly what I want to happen. I want when I select the staff on form frmManager2 it is saved in the table tblMeasure as MUserLoginID, then when I enter form frmMMeasures it is reflected on the form in the textbox MUserLoginID. Based on the code posted above I added the lines in red to the cmdMeasures_Click () but it still is not recorded in the tblMeasure and the value is not passed to the form open. Any help will be welcomed.

    Thanks.

    Code:
    Private Sub cmdMeasures_Click()
        On Error GoTo cmdMeasures_Click_Err
        If IsNull(Me.cboDeptName) Then
            MsgBox "You need to select a Department!", vbCritical
            Me.cboDeptName.SetFocus
        Exit Sub
        End If
        
        If IsNull(Me.cboPositionName) Then
            MsgBox "You need to selct the Position!", vbCritical
            Me.cboPositionName.SetFocus
        Exit Sub
        End If
        
        If IsNull(Me.cboStaff) Then
            MsgBox "You need to select the staff being appraised!", vbCritical
            Me.cboStaff.SetFocus
        Exit Sub
        End If
        
    DoCmd.OpenForm "frmMMeasures", , , "MUserLoginID = " & Me.cboStaff  
    DoCmd.Close acForm, "frmManager2"
     
    
    cmdMeasures_Click_Exit:
        Exit Sub
    
    cmdMeasures_Click_Err:
        MsgBox Error$
        Resume cmdMeasures_Click_Exit
    
    End Sub

  9. #9
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    1) I would generally save the selected value into a TempVar variable, where it would be automatically available everywhere.

    2) I don't see any problems with the code you posted, but it doesn't do what you think it does. It opens the form, using a filter that limits the results of the record's query to those records where MUserLoginID is equal to the value in Me.cboStaff.

    If you are expecting to create a new record, then you probably need to also set the default value for MUserLoginID in the form, and possible also set the dataentry mode to yes.

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

Similar Threads

  1. Replies: 15
    Last Post: 12-10-2012, 06:37 PM
  2. Replies: 3
    Last Post: 07-25-2012, 10:35 AM
  3. Replies: 3
    Last Post: 04-25-2012, 02:14 PM
  4. Replies: 3
    Last Post: 12-28-2011, 02:51 PM
  5. Displaying Queries Correctly
    By cgjames in forum Reports
    Replies: 0
    Last Post: 01-18-2011, 06:54 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