Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    PMFJI,

    @Shank, there are 2 reasons for the error message. Looking at the following code (i've refactored the code)
    Code:
    sSQL = sSQL & " WHERE [NoSkus]=""" & Me.txtGroupNoSkus & """ & [MustShipFrom] =""" & Me.txtGroupWhsID & [Sku] = """ & Me.txtGroupSku & """""
    1) The field "NoSkus" is a number (double???) field which does not need delimiters.
    2) The fields "MustShipFrom" and "Sku" need/require delimiters because they are text fields.
    3) The WHERE clause NEEDS/REQUIRES either an "OR" or an "AND" between the criteria.

    This is what the WHERE clause look like:
    Code:
    sSQL = sSQL & " WHERE [NoSkus]= " & Me.txtGroupNoSkus  & " AND [MustShipFrom] = '" & Me.txtGroupWhsID & "' AND [Sku] = '" & Me.txtGroupSku & "'"
    Note: I delimit Text with single quotes.

    Here is the WHERE clause is again, maybe easier to see:

    Code:
    WHERE 
    [NoSkus]= " & Me.txtGroupNoSkus  & " AND            '<<-- No delimiters needed because [NoSkus] is a Number field
    [MustShipFrom] = '" & Me.txtGroupWhsID & "' AND     '<<-- Delimiters needed because [MustShipFrom] is a Text field 
    [Sku] = '" & Me.txtGroupSku & "'"                   '<<-- Delimiters needed because [Sku] is a Text field
    The same goes for the Sub cmdUnselectAll_Click(). In this case you can use the same WHERE clause

    Code:
    Private Sub cmdSelectAll_Click()
        Dim sSQL As String
    
        sSQL = "Update [PODetail Temp ShipThese] SET [ShipThese]=True "
        sSQL = sSQL & " WHERE [NoSkus]= " & Me.txtGroupNoSkus & " AND [MustShipFrom] ='" & Me.txtGroupWhsID & "' AND [Sku] = '" & Me.txtGroupSku & "'"
        Debug.Print sSQL
        
        CurrentDb.Execute sSQL, dbFailOnError
        Me.subShipThese.Requery
    End Sub
    
    Private Sub cmdUnselectAll_Click()
        Dim sSQL As String
    
        sSQL = "Update [PODetail Temp ShipThese] SET [ShipThese]=False "
        sSQL = sSQL & " WHERE [NoSkus]= " & Me.txtGroupNoSkus & " AND [MustShipFrom] ='" & Me.txtGroupWhsID & "' AND [Sku] = '" & Me.txtGroupSku & "'"
        Debug.Print sSQL
        
        CurrentDb.Execute sSQL, dbFailOnError
        Me.subShipThese.Requery
    End Sub

    I removed the Link Master Field and the Link Child Field because the data is from the same table. I added a criteria to the sub form record source.



    Other issues:


    1) You should not use spaces in object names. (I removed the spaces from the table name.)


    2) EVERY module should have these two lines at the top:
    Code:
    Option Compare Database
    Option Explicit

    3) Every table should have a PK field (of type Autonumber - IMHO)
    Attached Files Attached Files

  2. #17
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188
    Vlad - Excellent! I see where you changed to singe quotes around an integer. I thought I tried every combination, but obviously not.

    Much appreciated!

  3. #18
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188
    Steve - I downloaded and will compare to Vlad's. Vlad's Rev2 works as expected, but I need to learn more and appreciate your input!

    Thank you!

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

Similar Threads

  1. Replies: 3
    Last Post: 10-05-2017, 08:10 AM
  2. checkbox and Textbox link
    By rebel_yell in forum Access
    Replies: 10
    Last Post: 05-13-2014, 04:46 PM
  3. Link from report to record form
    By John2360 in forum Access
    Replies: 8
    Last Post: 08-13-2013, 01:29 PM
  4. Open Form and Link To Specific Record
    By burrina in forum Forms
    Replies: 2
    Last Post: 12-17-2012, 11:09 PM
  5. Replies: 4
    Last Post: 07-31-2012, 04:33 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