Results 1 to 13 of 13
  1. #1
    MP BILL is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    8

    Post How to use lookup table values in a form as a Label


    Hello, I am a novice when it comes to Access programming. I am trying to take a values set in a table (by Pt#) and use them on a new input form as a label only. Would I create the form as a sub form and Lock the fields? Help is greatly appreciated

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    A subform is not necessarily needed to show related info from lookup table. Possibly you just need to join the tables in form's RecordSource and set the jointype to 'Include all records from <master table name>...', then bind and lock textboxes. Would have to know more about data structure. Want to provide file 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
    MP BILL is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    8
    Quote Originally Posted by June7 View Post
    A subform is not necessarily needed to show related info from lookup table. Possibly you just need to join the tables in form's RecordSource and set the jointype to 'Include all records from <master table name>...', then bind and lock textboxes. Would have to know more about data structure. Want to provide file for analysis? Follow instructions at bottom of my post.

    I have attached the File as you requested. I am looking to:

    a) take values set in a table (Tbl Value Set)Based on the part number selected at top of inspection main form and use the value as a label for an input form (FrmIn_InspDataSubform)
    b) also use the values to set conditions on the input fields of (FrmIn-InspDataSubform).

    Your help is greatly appreciated...
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    So you are not trying to print a set of labels (mailing labels, folder labels). You want to set the Caption property of the label controls on FrmIn_InspDataSubform also to set the ValidationRule property of textboxes? Never done anything like this. Expect will need VBA code in the form Current event. This code behind FrmIn_InspDataSubform works:
    Code:
    Private Sub Form_Load()
    Dim i As Integer
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    rs.Open "SELECT * FROM TblInspSet_Values WHERE cboSPartNumID=" & Form_FrmIncoming_Insp.cboSPartNumID & ";", CurrentProject.Connection, adOpenStatic, adLockPessimistic
    For i = 1 To 8
       Me.Controls("strINSPdata" & i & "_Label").Caption = rs.Fields("strINSPV" & i)
       'following is suggestion for the ValidationRule property, not tested
       Me.Controls("strINSPdata" & i).ValidationRule = rs.Fields("field name prefix here" & i)
    Next
    End Sub
    Need to set VBA reference: Microsoft Office 12.0 Object Library
    Last edited by June7; 08-09-2012 at 05:28 PM.
    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.

  5. #5
    MP BILL is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    8
    June7...added code to as Event procedure on the Subform "On Load"... Code does initially change the labels, however, when I add the next record, the labels remain the same...(do not change with the selected pt#). Should I add code to re-query and move code to "On Current" to handle record changes. What you have provided has been much help and much aprreciated...

  6. #6
    MP BILL is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    8
    Code works well under "On Current" I still need to look at why I am getting a type mismatch dialog when changing record.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Okay, the code will have to be executed when the forms open and when a part number is selected. This means code behind the main form that refers to the subform. I am having problem with syntax for that.

    I notice there are no values for labels 9 and 10 so the code errors if changed to loop 10 times. Also, the code will error if no matching record in TblInspSet_Values.

    Why using combobox DblClick event instead of AfterUpdate?
    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
    MP BILL is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    8
    I am sorry, I do not understand exactly where the code needs to go? On what form or what condition (e.g. Main form (FrmIncomin_Insp) under "On Load" as an event procedure.....) I apologize as being a novice has it draw backs...

  9. #9
    MP BILL is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    8
    the double click is being used to allow the user to add a part number that may not be there
    Parts being inspected could have 1 - 10 inspection criteria's, the reason for empty (null) values in certain fields...

  10. #10
    MP BILL is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    8
    Parts being inspected could have 1 - 10 inspection criteria's, the reason for empty (null) values in certain fields...

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I have the procedure under the Load event of the subform and am trying to have code in the AfterUpdate event of combobox call the subform Load event. I know how to do that with primary forms but syntax for calling procedure of subform (in this case a subsubform) eludes me.

    Right now there is no error handling in the code.
    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.

  12. #12
    MP BILL is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    8
    all Forms are linked via the the master and Child Fields... Would that need to be called out as the identifier to the part number and subform fields

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The Master/Child fields are not pertinent to the issue. The issue is syntax for referencing form (and its controls) when it is the SourceObject of a subform container control. The subform container control is a 'middle man' and must be considered in the syntax. This is what I am struggling with.
    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.

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

Similar Threads

  1. Replies: 5
    Last Post: 06-14-2012, 08:30 AM
  2. Replies: 7
    Last Post: 05-31-2012, 02:25 PM
  3. Lookup values after entering data in form
    By Hulkdog in forum Forms
    Replies: 2
    Last Post: 01-23-2012, 12:31 PM
  4. Replies: 5
    Last Post: 12-21-2011, 07:16 PM
  5. table lookup / null field values, help!
    By benjammin in forum Forms
    Replies: 3
    Last Post: 07-27-2011, 01:56 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