Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
  1. #16
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262

    Drawing numbers are in the DRAWINGS table. All others are in the PartsDatabase table. How do I put this condition into code?

    The combo boxes row source: SELECT [PDatabase].[PartNumber], [PDatabase].[Description], [PDatabase].[PurchaseUOM] FROM [PDatabase] ORDER BY [PartNumber] UNION SELECT [Drawing], Null, Null FROM [DRAWINGS] UNION SELECT [AssemblyKitNumber], Null, Null FROM [ASSEMBLIESKITS];

  2. #17
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    That still doesn't tell me how a drawing number can be distinguished from a part number. Are they different number characters? Does one start with a letter? Exactly how are they different?

    But maybe don't need.

    There are 3 entities in that combobox RowSource. Do you want the AssemblyKitNumber to be concatenated as well as Drawing number?

    Since only part number has values in 2nd and 3rd columns, the IIf() can use that to determine if selected item is a part number. Reference the combobox column by index. Index begins with 0.

    " VALUES ('" & Me.txtAlternateC & "','" & Me.txtAltCDescription & IIf(IsNull(Me.combobox.Column(1)), ", REF: " & Me.comboxname, "") & " \ALT" & "','" & Me.txtAltCUOM & "','" & Me.txtCageCodeC & "')"
    Last edited by June7; 06-08-2015 at 09:33 AM.
    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. #18
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    As far as the drawing and part numbers themselves, they can be anything.

    The AssemblyKitNumber is not in use, so I can literally take that out of the rowsource. It was an experiment that ended up not being suitable with Access.

    I tried your code and I (THINK) I adjusted it correctly for all the alternates. It didn't work. See below.

    Here's what I got:

    Click image for larger version. 

Name:	postcode1.png 
Views:	6 
Size:	36.3 KB 
ID:	20942

    Here's what I would like:

    Click image for larger version. 

Name:	postcode1desired.png 
Views:	6 
Size:	38.1 KB 
ID:	20943


    Here's the code I modified (I probably did it wrong, hehe):



    Code:
        'If there is an AlternateA, Add AlternateA
        If Not (Me.txtAlternateA & "" = "" And Me.txtCageCodeA & "" = "") Then
        CurrentDb.Execute "INSERT INTO BOM(Component, Description, UOM, CageCode) " & _
        " VALUES ('" & Me.txtAlternateA & "','" & Me.txtAltADescription & IIf(IsNull(Me.cboComponent.Column(1)), ", REF: " & Me.cboComponent, "") & " \ALT" & "','" & Me.txtAltAUOM & "','" & Me.txtCageCodeA & "')"
        End If
        
        'If there is an AlternateB, Add AlternateB
        If Not (Me.txtAlternateB & "" = "" And Me.txtCageCodeB & "" = "") Then
        CurrentDb.Execute "INSERT INTO BOM(Component, Description, UOM, CageCode) " & _
    " VALUES ('" & Me.txtAlternateB & "','" & Me.txtAltBDescription & IIf(IsNull(Me.cboComponent.Column(1)), ", REF: " & Me.cboComponent, "") & " \ALT" & "','" & Me.txtAltBUOM & "','" & Me.txtCageCodeB & "')"
        End If
        
        'If there is an AlternateC, Add AlternateC
        If Not (Me.txtAlternateC & "" = "" And Me.txtCageCodeC & "" = "") Then
        CurrentDb.Execute "INSERT INTO BOM(Component, Description, UOM, CageCode) " & _
        " VALUES ('" & Me.txtAlternateC & "','" & Me.txtAltCDescription & IIf(IsNull(Me.cboComponent.Column(1)), ", REF: " & Me.cboComponent, "") & " \ALT" & "','" & Me.txtAltCUOM & "','" & Me.txtCageCodeC & "')"
        End If

  4. #19
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Okay, maybe a combobox column can't hold a Null. Maybe the Null fields will be presented as empty string.

    IIf(Me.cboComponent.Column(1)="",
    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. #20
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    That got the REF: working. Now I just need to add the drawing number as the first record. No description or UOM or anything needed for it.

  6. #21
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Thought you already have code for that.
    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.

  7. #22
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    I do not. But I imagine it would be similar to the Iif statement. I can't get the syntax right.

  8. #23
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Oh, I was looking at the code for 'main part'. The record for Drawing number should be similar. Show attempted code.

    Probably want it inside an If Then conditional.
    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.

  9. #24
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Code:
        'Add drawing number if applicable
              CurrentDb.Execute "INSERT INTO BOM(Assembly, Component) " & _
        " VALUES ('" & Me.txtAssembly & "','" IIf(Me.cboComponent.Column(1) = "", & Me.cboComponent & "'),"")

  10. #25
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Missing & for concatenation.

    However, don't think that's where you need the conditional. What you have will add the record even if the selection is not a drawing number.

    If Me.cboComponent.Column(1) = "" Then
    'Add drawing number if applicable
    CurrentDb.Execute "INSERT INTO BOM(Assembly, Component) " & _
    " VALUES ('" & Me.txtAssembly & "','" & Me.cboComponent & "')"
    End If
    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. #26
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Works like a charm! Thank you!

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Apply formatting to query results
    By Access_Novice in forum Queries
    Replies: 5
    Last Post: 09-11-2014, 02:22 PM
  2. Replies: 3
    Last Post: 08-02-2013, 12:18 PM
  3. how to apply Conditional Formatting in run time
    By selvakumar.arc in forum Forms
    Replies: 7
    Last Post: 07-03-2013, 12:41 PM
  4. Conditional Formatting with more than 3 conditions
    By cactuspete13 in forum Programming
    Replies: 3
    Last Post: 12-10-2012, 01:03 PM
  5. code to apply control formatting
    By tariq1 in forum Programming
    Replies: 3
    Last Post: 07-21-2012, 12:36 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