Page 3 of 3 FirstFirst 123
Results 31 to 44 of 44
  1. #31
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86
    Brilliant. This post has made me bang my head against the wall a few times but we got there in the end. I've learned a lot from your help and have a clearer understanding of using the back end of Access with events. This is my first Access application and am learning everyday and am enjoying it. Just want to say I appreciate you support so thanks. I'll mark the post as read once I've tested the form thoroughly.

  2. #32
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86
    I have another issue. My frmProduct is linked to a main navigation form. When I open the Navigation Form the frmProduct which is linked to it produces parameter errors...

    Click image for larger version. 

Name:	Query.PNG 
Views:	16 
Size:	2.4 KB 
ID:	30579 Click image for larger version. 

Name:	Query 2.PNG 
Views:	16 
Size:	2.4 KB 
ID:	30580

    After reading up I believe I need to alter these lines in the code...

    Code:
    [Forms]![frmProduct]![allocated_bin_1]
    [Forms]![frmProduct]![allocated_bin_2]
    I've tried changing them to the following but it still does not work...

    Code:
    [Forms]![frmNavigation]![frmProduct].[form]![allocated_bin_1]
    [Forms]![frmNavigation]![frmProduct].[form]![allocated_bin_2]
    
    and
    
    [Forms]![frmNavigation]![frmProduct]![allocated_bin_1]
    [Forms]![frmNavigation]![frmProduct]![allocated_bin_2]
    How do I make this work so that frmProduct works when opened by itself and when in frmNavigation?

  3. #33
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Because the comboboxes are on the same form, try not including the form prefix.

    "WHERE (((AllocatedUNION.AllocatedBin)=[allocated_bin_1] Or (AllocatedUNION.AllocatedBin) Is Null)) " & _

    "WHERE (((AllocatedUNION.AllocatedBin)=[allocated_bin_2] Or (AllocatedUNION.AllocatedBin) Is Null)) " & _
    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.

  4. #34
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86
    Hi

    Sorry for bringing an old post up but I've found a bug on this form.

    When I open the form up and click the drop down "Search Product" I select the top product in the list which then populates my form, for some reason the "Master Bin" and "Secondary Bin" don't populate. This only happens with the top product in the list for some reason. If I start click around the form and go back to it then eventually it shows up, any idea what is causing this?

    Click image for larger version. 

Name:	Capture.PNG 
Views:	11 
Size:	14.2 KB 
ID:	32240


    This is the current code on the form.

    HTML Code:
    Option Compare Database
    Option Explicit
    
    Private Sub Form_Current()
    'Script for the product page which removes used bins from the bin combo box list so it only shows available bins.
    'Also displays the selected bin in the combo box text field
    Me.secondaryBinSelectBox.Enabled = Not IsNull(Me.masterBinSelectBox)   
    If Me.NewRecord Then
    Me.masterBinSelectBox.RowSource = "SELECT tblAllocatedBin.allocated_bin_id, tblBin.bin, tblBinType.bin_type " & _
    "FROM tblBinType RIGHT JOIN (tblBin LEFT JOIN (qryAllocatedBinsToProduct RIGHT JOIN tblAllocatedBin ON " & _
    "qryAllocatedBinsToProduct.AllocatedBin = tblAllocatedBin.allocated_bin_id) ON tblBin.bin_id = tblAllocatedBin.allocated_bin) ON " & _
    "tblBinType.bin_type_id = tblAllocatedBin.allocated_bin_type " & _
    "WHERE qryAllocatedBinsToProduct.AllocatedBin Is Null " & _
    "ORDER BY tblBin.bin, tblBinType.priority;"
    
     Me.secondaryBinSelectBox.RowSource = "SELECT tblAllocatedBin.allocated_bin_id, tblBin.bin, tblBinType.bin_type " & _
    "FROM tblBinType RIGHT JOIN (tblBin LEFT JOIN (qryAllocatedBinsToProduct RIGHT JOIN tblAllocatedBin ON " & _
    "qryAllocatedBinsToProduct.AllocatedBin = tblAllocatedBin.allocated_bin_id) ON tblBin.bin_id = tblAllocatedBin.allocated_bin) ON " & _
    "tblBinType.bin_type_id = tblAllocatedBin.allocated_bin_type " & _
    "WHERE qryAllocatedBinsToProduct.AllocatedBin Is Null " & _
    "ORDER BY tblBin.bin, tblBinType.priority;"
    Else
    Me.masterBinSelectBox.RowSource = "SELECT tblAllocatedBin.allocated_bin_id, tblBin.bin, tblBinType.bin_type " & _
     "FROM tblBinType RIGHT JOIN (tblBin LEFT JOIN (qryAllocatedBinsToProduct RIGHT JOIN tblAllocatedBin ON " & _
    "qryAllocatedBinsToProduct.AllocatedBin = tblAllocatedBin.allocated_bin_id) ON tblBin.bin_id = tblAllocatedBin.allocated_bin) ON " & _
    "tblBinType.bin_type_id = tblAllocatedBin.allocated_bin_type " & _
    "WHERE (((qryAllocatedBinsToProduct.AllocatedBin)=[allocated_bin_1] Or (qryAllocatedBinsToProduct.AllocatedBin) Is Null)) " & _
    "ORDER BY tblBin.bin, tblBinType.priority;"
    
    Me.secondaryBinSelectBox.RowSource = "SELECT tblAllocatedBin.allocated_bin_id, tblBin.bin, tblBinType.bin_type " & _
    "FROM tblBinType RIGHT JOIN (tblBin LEFT JOIN (qryAllocatedBinsToProduct RIGHT JOIN tblAllocatedBin ON " & _
    "qryAllocatedBinsToProduct.AllocatedBin = tblAllocatedBin.allocated_bin_id) ON tblBin.bin_id = tblAllocatedBin.allocated_bin) ON " & _
    "tblBinType.bin_type_id = tblAllocatedBin.allocated_bin_type " & _
     "WHERE (((qryAllocatedBinsToProduct.AllocatedBin)=[allocated_bin_2] Or (qryAllocatedBinsToProduct.AllocatedBin) Is Null)) " & _
    "ORDER BY tblBin.bin, tblBinType.priority;"
    End If
    Me.masterBinSelectBox.Requery
    Me.secondaryBinSelectBox.Requery
    End Sub
    
    Private Sub Form_Load()    
    'Makes the form default to add new entry    
    DoCmd.GoToRecord , , acNewRec
    End Sub
    
    Private Sub masterBinSelectBox_GotFocus()    
    Me.masterBinSelectBox.Dropdown    
    End Sub
    
    Private Sub masterBinSelectBox_AfterUpdate()   
    Me.secondaryBinSelectBox.Enabled = Not IsNull(Me.masterBinSelectBox)
    End Sub
    
    Private Sub secondaryBinSelectBox_GotFocus()    
    Me.secondaryBinSelectBox.Dropdown
    End Sub
    
    Private Sub productSearchBox_GotFocus()    
    Me.productSearchBox.Dropdown    
    Me.productSearchBox.Requery
    End Sub

  5. #35
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Posted code is not readable. Please edit.
    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. #36
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86
    Sorry, I've edited it, see above.

  7. #37
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Don't see any issue with code. Expect I would have to review db to analyze.
    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. #38
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86
    I've uploaded the file, see attached.

    Planner.zip

  9. #39
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,776
    Only took a brief look I admit (running out of time here) but isn't this due to improper referencing of form controls when the form is on a navigation form? It can be compounded by changing the default name for the nav form and forgetting that as well. I think the syntax is
    Code:
    Forms!NavFormName.NavigationSubform.Form.ControlName
    not

    [Forms]![frmNavigation]![frmProduct].[form]![allocated_bin_2] or
    [Forms]![frmNavigation]![frmProduct]![allocated_bin_2]

    The default name for the navigation subform control is bolded red above. Unless its name was changed, the object appears to be missing from the reference.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #40
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Form prefix not needed.

    References to allocated_bin_1 and allocated_bin_2 are field names, not controls.

    Concatenate the field names to pull value from current record.

    "WHERE (((qryAllocatedBinsToProduct.AllocatedBin)=" & [allocated_bin_1] & " Or (qryAllocatedBinsToProduct.AllocatedBin) Is Null)) " & _

    "WHERE (((qryAllocatedBinsToProduct.AllocatedBin)=" & [allocated_bin_2] & " Or (qryAllocatedBinsToProduct.AllocatedBin) Is Null)) " & _
    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.

  11. #41
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86
    Quote Originally Posted by June7 View Post
    Form prefix not needed.

    References to allocated_bin_1 and allocated_bin_2 are field names, not controls.

    Concatenate the field names to pull value from current record.

    "WHERE (((qryAllocatedBinsToProduct.AllocatedBin)=" & [allocated_bin_1] & " Or (qryAllocatedBinsToProduct.AllocatedBin) Is Null)) " & _

    "WHERE (((qryAllocatedBinsToProduct.AllocatedBin)=" & [allocated_bin_2] & " Or (qryAllocatedBinsToProduct.AllocatedBin) Is Null)) " & _
    I've changed the code as suggested but the first entry in my search box drop down doesn't populate the Master and Secondary Bin values. Below is my code.

    HTML Code:
    Option Compare DatabaseOption Explicit
    
    Private Sub Form_Current()
    'Script for the product page which removes used bins from the bin combo box list so it only shows available bins.
    'Also displays the selected bin in the combo box text fieldMe.secondaryBinSelectBox.Enabled = Not IsNull(Me.masterBinSelectBox)
    If Me.NewRecord Then
    Me.masterBinSelectBox.RowSource = "SELECT tblAllocatedBin.allocated_bin_id, tblBin.bin, tblBinType.bin_type, tblBin.bin_width_mm " & _
    "FROM tblBinType RIGHT JOIN (tblBin LEFT JOIN (qryAllocatedBinsToProduct RIGHT JOIN tblAllocatedBin ON " & _
    "qryAllocatedBinsToProduct.AllocatedBin = tblAllocatedBin.allocated_bin_id) ON tblBin.bin_id = tblAllocatedBin.allocated_bin) ON " & _
    "tblBinType.bin_type = tblAllocatedBin.allocated_bin_type " & _
    "WHERE (((qryAllocatedBinsToProduct.AllocatedBin) Is Null)) " & _
    "ORDER BY tblBin.bin, tblBinType.priority;"
    
    Me.secondaryBinSelectBox.RowSource = "SELECT tblAllocatedBin.allocated_bin_id, tblBin.bin, tblBinType.bin_type, tblBin.bin_width_mm " & _
    "FROM tblBinType RIGHT JOIN (tblBin LEFT JOIN (qryAllocatedBinsToProduct RIGHT JOIN tblAllocatedBin ON " & _
    "qryAllocatedBinsToProduct.AllocatedBin = tblAllocatedBin.allocated_bin_id) ON tblBin.bin_id = tblAllocatedBin.allocated_bin) ON " & _
    "tblBinType.bin_type = tblAllocatedBin.allocated_bin_type " & _"WHERE (((qryAllocatedBinsToProduct.AllocatedBin) Is Null)) " & _
    "ORDER BY tblBin.bin, tblBinType.priority;"ElseMe.masterBinSelectBox.RowSource = "SELECT tblAllocatedBin.allocated_bin_id, tblBin.bin, tblBinType.bin_type, tblBin.bin_width_mm " & _
    "FROM tblBinType RIGHT JOIN (tblBin LEFT JOIN (qryAllocatedBinsToProduct RIGHT JOIN tblAllocatedBin ON " & _
    "qryAllocatedBinsToProduct.AllocatedBin = tblAllocatedBin.allocated_bin_id) ON tblBin.bin_id = tblAllocatedBin.allocated_bin) ON " & _
    "tblBinType.bin_type = tblAllocatedBin.allocated_bin_type " & _"WHERE (((qryAllocatedBinsToProduct.AllocatedBin)=" & [allocated_bin_1] & " Or (qryAllocatedBinsToProduct.AllocatedBin) Is Null)) " & _
    "ORDER BY tblBin.bin, tblBinType.priority;"
    Me.secondaryBinSelectBox.RowSource = "SELECT tblAllocatedBin.allocated_bin_id, tblBin.bin, tblBinType.bin_type, tblBin.bin_width_mm " & _
    "FROM tblBinType RIGHT JOIN (tblBin LEFT JOIN (qryAllocatedBinsToProduct RIGHT JOIN tblAllocatedBin ON " & _
    "qryAllocatedBinsToProduct.AllocatedBin = tblAllocatedBin.allocated_bin_id) ON tblBin.bin_id = tblAllocatedBin.allocated_bin) ON " & _
    "tblBinType.bin_type = tblAllocatedBin.allocated_bin_type " & _"WHERE (((qryAllocatedBinsToProduct.AllocatedBin)=" & [allocated_bin_2] & " Or (qryAllocatedBinsToProduct.AllocatedBin) Is Null)) " & _
    "ORDER BY tblBin.bin, tblBinType.priority;"
    End If
    Me.masterBinSelectBox.RequeryMe.secondaryBinSelectBox.Requery
    End Sub
    
    Private Sub Form_Load()
    'Makes the form default to add new entry
    DoCmd.GoToRecord , , acNewRec
    End Sub
    
    Private Sub masterBinSelectBox_GotFocus()
    Me.masterBinSelectBox.Dropdown
    End Sub
    
    Private Sub masterBinSelectBox_AfterUpdate()
    Me.secondaryBinSelectBox.Enabled = Not IsNull(Me.masterBinSelectBox)
    End Sub
    
    Private Sub secondaryBinSelectBox_GotFocus()
    Me.secondaryBinSelectBox.Dropdown
    End Sub
    
    Private Sub productSearchBox_GotFocus()
    Me.productSearchBox.Dropdown
    Me.productSearchBox.Requery
    End Sub

  12. #42
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Recommend convert embedded macros to VBA

    Recommend not setting lookups in tables

    Did a bunch of trial and error and observed a lot of bizarre behavior.

    1. selecting first item is not triggering OnCurrent event

    2. changed combobox to sort on allocated_bin_1 and now the first item triggers OnCurrent but value 1W05ACBA04AM does not and it is in row 20

    3. removed sorting from combobox RowSource and no value in first row triggers OnCurrent

    4. again set sorting on allocated_bin_1 and added an 'x' in front of 1W05ACBA04AM and now 2400-0200-123123123 will not trigger event

    5. put in an 'x' in front of 2400-0200-123123123 and now 2500-1100 will not trigger event

    6. put in an 'x' in front of 2500-1100 and all values trigger event

    7. set sorting back to product field and again first row will not trigger event

    I am at a total loss as to why this is the case.
    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.

  13. #43
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86
    Quote Originally Posted by June7 View Post
    Recommend convert embedded macros to VBA

    Recommend not setting lookups in tables

    Did a bunch of trial and error and observed a lot of bizarre behavior.

    1. selecting first item is not triggering OnCurrent event

    2. changed combobox to sort on allocated_bin_1 and now the first item triggers OnCurrent but value 1W05ACBA04AM does not and it is in row 20

    3. removed sorting from combobox RowSource and no value in first row triggers OnCurrent

    4. again set sorting on allocated_bin_1 and added an 'x' in front of 1W05ACBA04AM and now 2400-0200-123123123 will not trigger event

    5. put in an 'x' in front of 2400-0200-123123123 and now 2500-1100 will not trigger event

    6. put in an 'x' in front of 2500-1100 and all values trigger event

    7. set sorting back to product field and again first row will not trigger event

    I am at a total loss as to why this is the case.
    This bug is driving me nuts, I've spent all day trying to figure out a work around. If I navigate to the first entry using the navigation buttons then the bin shows up but as soon as I use the search box for the first entry it doesn't show again. As it works with the nav buttons is there some sort event I can trigger in the script after selecting the item in the search box to refresh it?

    Also if I change the Bound Column from 1 to 2 on the Master and Secondary Bins to show an ID instead of a Bin number then it works as expected.

  14. #44
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86
    I managed to work out a quirky solution to the first entry not populating the bin numbers. I added this to my code...

    HTML Code:
    Private Sub productSearchBox_Click()
    If Me.Recordset.AbsolutePosition = 0 Then
    DoCmd.GoToRecord Record:=acNext
    DoCmd.GoToRecord Record:=acPrevious
    End If
    Me.masterBinSelectBox.Requery
    Me.secondaryBinSelectBox.Requery
    End Sub

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Matching 2 tables with no unique fields
    By ernest_rhaniel in forum Queries
    Replies: 15
    Last Post: 03-21-2017, 11:28 PM
  2. Replies: 1
    Last Post: 02-09-2016, 09:03 PM
  3. Select unique values from multiple fields
    By MrDummy in forum Queries
    Replies: 2
    Last Post: 12-07-2015, 01:42 PM
  4. Replies: 5
    Last Post: 03-17-2014, 04:02 PM
  5. Unique Values and Boolean Fields
    By Triad in forum Forms
    Replies: 1
    Last Post: 07-15-2010, 06:28 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