Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    the first message box ("Option (criteria) selected is ") is displayed;
    but, nothing afterwards (including the second: "Number of records = ")

    I checked the spelliong of tblFixtureSchedulePrintOptions, PresetOption, and frmPresetOption - all are correct, and frmPresetOption is a number field

  2. #17
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by markjkubicki View Post
    the first message box ("Option (criteria) selected is ") is displayed;
    but, nothing afterwards (including the second: "Number of records = ")

    I checked the spelliong of tblFixtureSchedulePrintOptions, PresetOption, and frmPresetOption - all are correct, and frmPresetOption is a number field

    OK, Try this:

    Code:
    Dim sSQL As String
    '==============================
    'for testing
    '==============================
    Dim R as DAO.Recordset
    Dim RC as Long 'record count
    
    MsgBox "Option (criteria) selected is " & Me.frmPresetOption
    
    sSQL = " SELECT *" _
    sSQL = sSQL & " FROM tblFixtureSchedulePrintOptions"
    sSQL = sSQL & " WHERE [PresetOption] = " & Me.frmPresetOption & ";"
    
    MsgBox "sSQL = " & sssql
    
    ' open recordset
    
    'my spelling error
    Set R = Currentdb.OpenRecordset(sSQL)
    RC = R.Recordcount
    R.Close
    Set R = Nothing
    MsgBox "Number of records = " & RC
    '==============================
    'end testing
    '==============================
    
    
    'clear table
    sSQL = "Delete * from [tbeFixtureSchedulePrintOptions];"
    CurrentDB.Execute sSQL, dbfailonerror
    'append new record
    sSQL = "INSERT INTO tbeFixtureSchedulePrintOptions" _
    & " SELECT *" _
    & " from tblFixtureSchedulePrintOptions" _
    & " WHERE [PresetOption] = " & Me.frmPresetOption & ";"
    
    MsgBox "Insert string = " & ssql
    
    CurrentDB.Execute sSQL, dbfailonerror
    'requery current form
    Me.Requery
    Do the sSQL strings look right??

  3. #18
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    so, I tried the code, and got this information
    - the option number choosen - check
    - (1) matching record in the look-up table for that option - check
    - sSQL for the deletion syntax - check
    - sSQL fro the insert syntax -check
    - all good

    and then I changed the code (see below)
    and couldn't get past a stumbling block (noted in the code as: "this is where I got stuck.."


    here's the code i used:

    Private Sub frmPresetOption_beforeUpdate(Cancel As Integer)
    Dim sSQL As String
    '==============================
    'for testing
    '==============================
    Dim R As DAO.Recordset
    Dim rstTBE As DAO.Recordset
    Dim RC As Long 'record count
    MsgBox "Option (criteria) selected is " & Me.frmPresetOption

    ' test for matching record
    sSQL = " SELECT *"
    sSQL = sSQL & " FROM tblFixtureSchedulePrintOptions"
    sSQL = sSQL & " WHERE [PresetOption] = " & Me.frmPresetOption & ";"
    MsgBox "sSQL = " & sSQL
    Set R = CurrentDb.OpenRecordset(sSQL)
    RC = R.RecordCount
    R.Close
    Set R = Nothing
    MsgBox "Number of matching records records in TBL = " & RC

    '==============================
    'this next line is giving me trouble
    sSQL_TBE = "select * from [tbeFixtureSchedulePrintOptions];" 'tbeFixtureSchedulePrintOptions is spelled correctly
    Set rstTBE = sSQL_TBE
    RC = rstTBE.RecordCount
    MsgBox "RecordCount in TBE = " & RC
    '==============================

    'clear table
    sSQL = "Delete * from [tbeFixtureSchedulePrintOptions];"
    MsgBox "Delete string = " & sSQL

    CurrentDb.Execute sSQL, dbFailOnError

    RC = rstTBE.RecordCount
    MsgBox "RecordCount in TBE after delete = " & RC

    'append new record
    sSQL = "INSERT INTO tbeFixtureSchedulePrintOptions" _
    & " SELECT *" _
    & " from tblFixtureSchedulePrintOptions" _
    & " WHERE [PresetOption] = " & Me.frmPresetOption & ";"
    MsgBox "Insert string = " & sSQL
    CurrentDb.Execute sSQL, dbFailOnError
    RC = rstTBE.RecordCount
    MsgBox "RecordCount in TBE after delete = " & RC
    rstTBE.Close
    Set rstTBE = Nothing
    'requery current form
    Me.Requery
    '==============================

  4. #19
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Don't know if you solved this......

    Quote Originally Posted by markjkubicki View Post
    '==============================
    'this next line is giving me trouble
    sSQL_TBE = "select * from [tbeFixtureSchedulePrintOptions];" 'tbeFixtureSchedulePrintOptions is spelled correctly
    Set rstTBE = sSQL_TBE
    RC = rstTBE.RecordCount
    MsgBox "RecordCount in TBE = " & RC
    '==============================

    You can't just set the SQL equal to variable. Use:
    Code:
    Set rstTBE = Currentdb.OpenRecordset(sSQL_TBE)
    If not rstTBE.BOF and not rstTBE.EOF then
       rstTBE.MoveLast
       RC = rstTBE.RecordCount
       MsgBox "RecordCount in TBE = " & RC
       rstTBE.MoveFirst
    End If

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

Similar Threads

  1. Replies: 5
    Last Post: 06-29-2010, 01:24 PM
  2. Table not updating (Anyone Please Help)
    By goyal_cyber in forum Queries
    Replies: 7
    Last Post: 05-28-2010, 09:42 AM
  3. Updating another record table with command button
    By erlan501 in forum Programming
    Replies: 5
    Last Post: 04-26-2010, 09:03 AM
  4. FE & BE Updating
    By mastromb in forum Access
    Replies: 5
    Last Post: 02-12-2010, 11:55 AM
  5. Replies: 3
    Last Post: 06-27-2009, 03:53 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