Results 1 to 9 of 9
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Append Query From Form Syntax Error


    If DCount("*", "[TReg]", "[Bank] = " & RegID) <= 0 Then 'Purpose: Check is Bank Account Exists in TReg Table.

    Table being used on form is TBanks and table to apend to is TReg
    I wanted to check and see if the Bank was in the table and if not append it.
    Append query is appending form TBanks table to TReg table.

    Above code gives me an error saying; Syntax error (missing operator) in query expression {bank}
    There is ONLY one field in the append query and it is Bank and it is found in both tables.
    Bank field in TReg table uses limit to list, is this a problem? Bank field looks up Bank form table TBanks as a combo?
    Table TBanks has its Primary Key as bankid

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You say the DCount line is triggering error? I don't see anything wrong with DCount.

    The DCount refers to table and has nothing to do with APPEND query. Nor should the combobox LimitToList property bear on the DCount.
    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
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    It says syntax error in RegID so I have not gotten the code correct. RegID is the primary key in the check register and I am using this code on a form to try and open the check register and MAKE it keep the same bank account. Check Register form is a subform, a continuous subform at that and it uses a Union Query as its record source. On the main form it uses the same table as the subform just not a query. Bank is the field I want to keep as the same for all records on the subform. Maybe it can't be done? Anyway the code as it is will not work.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    This code is behind a form? Is RegID in the RecordSource of the form? RegID is the parameter to restrict the DLookup search in TReg table. If RegID is not coming from the current record on the form, it is meaningless.
    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
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Bank Form

    Yes, it is coming from a form that in theory is supposed to open the check register with that selection form the combo on the form that lists all of the banks. Choose a bank and then the check registry opens with that bank ONLY. Here is the code that is run. YES RegID is in the record source.
    On Error GoTo Err_ChkRegstr_Click

    If DCount("*", "[TReg]", "[RegID] = " & Bank) <= 0 Then 'Purpose: Check is Bank Account Exists is TReg Table.
    DoCmd.RunCommand acCmdSelectRecord
    Me.bankid.DefaultValue = """" & Me.bankid.Value & """"

    Dim stDocName As String 'Purpose: Open Check Register W/Selected Bank Account.
    Dim stLinkCriteria As String

    stDocName = "Copy Of FReg"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.Close acForm, Me.Name

    Exit_ChkRegstr_Click:

    Exit Sub

    Err_ChkRegstr_Click:
    MsgBox Err.Description
    Resume Exit_ChkRegstr_Click
    'End If
    End Sub
    Attached Thumbnails Attached Thumbnails Bank.jpg  
    Last edited by burrina; 01-02-2013 at 12:14 AM. Reason: Show Pic of Bank Form

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You show the RegID and Bank reversed in this code. Code still fails on this line?

    RegID is a number field. Is the combobox value also a number?
    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. #7
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Combo looks up both so that the ID is shown on the form but ONLY Bank is shown in the list. YES, RegID is a Primary Key "Number"

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Sounds like the DLookup is set up properly. I can't fathom why it isn't working.
    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. #9
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Me either. Thanks though. I will mark this as solved and move on. Bigger fish to fry! Thanks again.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  2. syntax error in query
    By zoe.ohara in forum Queries
    Replies: 6
    Last Post: 04-23-2011, 04:58 AM
  3. Urgent: SQL Append Query Syntax
    By rushforth in forum Import/Export Data
    Replies: 14
    Last Post: 02-23-2011, 02:44 PM
  4. Append Query Error
    By lupis in forum Queries
    Replies: 1
    Last Post: 06-18-2010, 02:10 AM
  5. append query error
    By shashigk in forum Queries
    Replies: 2
    Last Post: 09-22-2009, 07:17 AM

Tags for this Thread

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