Results 1 to 6 of 6
  1. #1
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231

    Run-Time error 3141

    I'm getting a run-time error 3141 regarding some select statement, but the program stops at a line that doesn't deal with a sql statement at all...?

    It stops at a line where I'm passing the open arguments to a form:



    DoCmd.OpenForm "frm_CREATE_PRODUCER", , , , , , MEMBER_ID

    Not sure what the error message is trying to tell me.......

    Any help would be appreciated......CementCarver

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    What is the Record Source of the form called "frm_CREATE_PRODUCER" that you are trying to open.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
    FYI, nice to have sometimes.

    http://www.fmsinc.com/microsoftacces...ption2007.html

    Dale

  4. #4
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    The following is the record source that I am using.....

    Set db = CurrentDb()
    strSQL = "SELECT FULLPACKER.[Business Name] from FULLPACKER WHERE [Business Name] = " & "'" & strBUSINESS_NAME & "'"

    Set rstPackerExists = db.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)

    If the name of business name doesn't exist, then I load that record and then try to call up the form to allow them input.

    CC

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by CementCarver View Post

    ...but the program stops at a line that doesn't deal with a sql statement at all...
    What is the line immediately prior to the highlighted line? The Access Gnomes have a bad habit of highlighting the line after the actual line that causes an error.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    Missinglinq,

    Below are the two modules in question: the incoming rstPacker and strBusiness_Name are set up in the calling module.

    .......Calling module......
    Private Sub Create_New_Packer_Click()
    Dim rstPacker As Recordset
    Dim strBUSINESS_NAME As String
    Dim db As Database

    Set db = CurrentDb
    Set rstPacker = db.OpenRecordset("FULLPACKER", adOpenDynamic, adLockOptimistic)

    strBUSINESS_NAME = [Forms]![BUSINESS_MAIN]![BUSINESS_NAME]

    'Call AddPacker Subroutine
    AddPacker rstPacker, strBUSINESS_NAME

    End Sub

    ....Receving module.....

    Private Sub AddPacker(rstPacker As Recordset, _
    strBUSINESS_NAME As String)

    Dim Grower_lnk As Integer
    Dim PackerLicence As String
    Dim grow_lic As String
    Dim PackName As String
    Dim PkCheckBox As Long
    'Dim intMEMBER_ID As Integer
    Dim rstPackerExists As Recordset
    Dim db As Database
    Dim strSQL As String

    PkCheckBox = Forms!BUSINESS_MAIN!Check_Packer

    If PkCheckBox <> 0 Then

    ElseIf PkCheckBox = 0 Then
    MsgBox "Please Select Packer Check Box before Proceeding"
    Exit Sub
    End If

    Set db = CurrentDb()
    strSQL = "SELECT FULLPACKER.[Business Name] from FULLPACKER WHERE [Business Name] = " & "'" & strBUSINESS_NAME & "'"
    Debug.Print strSQL

    Set rstPackerExists = db.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)

    PackerLicence = DMax("[PLICENCE]", "FULLPACKER")
    PackerLicence = PackerLicence + 1

    Debug.Print PackerLicence

    ' Insert packer record

    If rstPackerExists.EOF Then
    With rstPacker
    .AddNew
    ![Business Name] = strBUSINESS_NAME
    ![PLicence] = PackerLicence
    Grower_lnk = Forms!BUSINESS_MAIN!MEMBER_ID
    !MEMBER_ID = Grower_lnk
    .Update
    '.Bookmark = .LastModified
    End With
    DoCmd.Requery
    Me.Refresh
    rstPacker.Close
    End If

    If Not rstPackerExists.EOF Then
    MsgBox "Packer Record for: " & strBUSINESS_NAME & " already exists, Please proceed with edit session.", vbCritical
    Exit Sub
    End If

    PackName = strBUSINESS_NAME

    'Pass arguments to form load event

    DoCmd.OpenForm "frm_CREATE_PACKER", , , , , , Grower_lnk.............line that indicates the error.....

    'Open the form based on where clause

    'sWHERE = strBUSINESS_NAME

    DoCmd.OpenForm "frm_CREATE_PACKER", , , , , , Grower_lnk

    If Len(Grower_lnk) > 0 Then
    Forms!frm_CREATE_PACKER![MEMBER_ID].SetFocus
    DoCmd.GoToControl "MEMBER_ID_FULLPACKER"
    DoCmd.FindRecord Grower_lnk, , True, , True, , True
    End If


    MsgBox "New Packer Record Has Been Created for: " & PackName

    End Sub




    CC

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

Similar Threads

  1. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  2. Error: Run-time error '13' Type mismatch
    By uronmapu in forum Access
    Replies: 1
    Last Post: 09-07-2012, 05:38 AM
  3. Replies: 0
    Last Post: 07-16-2012, 05:42 AM
  4. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  5. Replies: 5
    Last Post: 03-27-2012, 01:40 PM

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