Page 4 of 5 FirstFirst 12345 LastLast
Results 46 to 60 of 65
  1. #46
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Just two*



    One thing I'd like to add to distinguish main parts from alternates is I want to add " \ALT" to the end of the description text of alternates automatically when I add them to my table.

    Also, If I add a part with an alternate A and NO alternateB, I get a blank line. Is there any way to eliminate records that are blank? DELETE IF statement?

    Click image for larger version. 

Name:	before.jpg 
Views:	3 
Size:	132.5 KB 
ID:	17065 ->Click image for larger version. 

Name:	after.jpg 
Views:	3 
Size:	140.8 KB 
ID:	17066

  2. #47
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Concatenation is simple:

    Me.txtAlternateA & "\Alt"

    Don't save the record if no value:

    If Not IsNull(Me.txtAlternateB) Then
    'save record
    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.

  3. #48
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Where do I place these statements?

  4. #49
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    In your VBA code.

    If Not IsNull(Me.txtAlternateB) Then
    CurrentDb.Execute "INSERT INTO EntryFormTable(Component, Description, UOM) " & _
    " VALUES ('" & Me.txtAlternateB & "\AltB" & "','" & Me.txtAltBDescription & "','" & Me.txtAltBUOM & "')"
    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.

  5. #50
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    I get this:

    Click image for larger version. 

Name:	FORM2.jpg 
Views:	3 
Size:	135.4 KB 
ID:	17068

    Add Code:

    Code:
    Private Sub butAdd_Click()
    
    
    'Insert vs Update options
    
    
    
    
    'If the part is not in the list
        If Me.txtComponent.Tag & "" = "" Then
    
    
    'add the part to the list
        
        CurrentDb.Execute "INSERT INTO EntryFormTable(Assembly, Component, Description, AssemblyQty, UOM, QtyA, QtyB, QtyC, UnitPriceA, UnitPriceB, UnitPriceC) " & _
        " VALUES ('" & Me.txtAssembly & "','" & Me.txtComponent & "','" & Me.txtDescription & "','" & Me.numAssemblyQty & "','" & Me.txtUOM & "','" & Me.numQtyA & "','" & _
        Me.numQtyB & "','" & Me.numQtyC & "','" & Me.dbPriceA & "','" & Me.dbPriceB & "','" & Me.dbPriceC & "')"
        
        If Not IsNull(Me.txtAlternateA) Then
        CurrentDb.Execute "INSERT INTO EntryFormTable(Component, Description, UOM) " & _
        " VALUES ('" & Me.txtAlternateA & "','" & Me.txtAltADescription & " \AltB" & "','" & Me.txtAltAUOM & "')"
        End If
        
        If Not IsNull(Me.txtAlternateB) Then
        CurrentDb.Execute "INSERT INTO EntryFormTable(Component, Description, UOM) " & _
        " VALUES ('" & Me.txtAlternateB & "','" & Me.txtAltBDescription & " \AltB" & "','" & Me.txtAltBUOM & "')"
        End If
        
    'update an already existing part
        Else
        CurrentDb.Execute "UPDATE EntryFormTable " & _
            " SET Assembly='" & Me.txtAssembly & "'" & _
            ", Component='" & Me.txtComponent & "'" & _
            ", Description='" & Me.txtDescription & "'" & _
            ", AssemblyQty='" & Me.numAssemblyQty & "'" & _
            ", UOM='" & Me.txtUOM & "'" & _
            ", QtyA='" & Me.numQtyA & "'" & _
            ", QtyB='" & Me.numQtyB & "'" & _
            ", QtyC='" & Me.numQtyC & "'" & _
            ", PriceA='" & Me.dbPriceA & "'" & _
            ", PriceB='" & Me.dbPriceB & "'" & _
            ", PriceC='" & Me.dbPriceC & "'" & _
            " WHERE Component='" & Me.frmEntrySub!Component & "'"
        End If
        
    'Clear form after add/update
        butClear_Click
    
    
    'Refresh form
        frmEntrySub.Form.Requery
    
    
    End Sub
    Changed \AltB to \Alt, A and B dont really matter here. Didn't make a difference Adding wise of course.

  6. #51
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Have you step debugged?
    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. #52
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    No. I've only done step debugging once years ago in C++.

  8. #53
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Does it matter that txtAlternateA is actually mislabeled, and is a combobox?

  9. #54
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Review link at bottom of my post for guidelines.

    And that answers question I was going to ask. No, the naming convention doesn't matter. Are they actually Null if no value shows?

    Don't you want "\AltA" for the AlternateA concatenation?
    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.

  10. #55
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    AlternateA and AlternateB are only useful for telling access how many records to add in that are different when I make an entry. In the final product, \ALT's are interchangeable.

  11. #56
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Then why bother with the "A" or "B" designation, just "\Alt"?
    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. #57
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Also, my debugging is not working. When I put my cursor over the line and press F8 or click it on the menu, nothing happens.

  13. #58
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    The A and B designation is to help match form fields to table fields.

  14. #59
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Did you place a breakpoint in the code? Then when code execution pauses on the breakpoint, hover over any variable to see its content. Reference to a control is a variable.
    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.

  15. #60
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Like this?

    Click image for larger version. 

Name:	bp1.jpg 
Views:	3 
Size:	147.8 KB 
ID:	17069

Page 4 of 5 FirstFirst 12345 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. 1 Combobox with values from 2 tables
    By Comsoft in forum Access
    Replies: 1
    Last Post: 04-23-2013, 05:42 PM
  2. Replies: 9
    Last Post: 01-17-2013, 09:08 PM
  3. Forms - ComboBox - Sort/Edit Tables
    By farner in forum Forms
    Replies: 3
    Last Post: 01-05-2013, 09:05 PM
  4. Replies: 1
    Last Post: 06-25-2012, 02:15 PM
  5. Replies: 0
    Last Post: 08-24-2010, 06:38 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