Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    ADP Conversion Question

    Well, I've gone through a rather laborious effort of importing objects and recreating those I that wouldn't import. I'm not done by any means, but I have come across a stumbling block I hope you can shed some light on. When clicking on a command button on the main form I received this error.
    Click image for larger version. 

Name:	Adp Conversion Project Error.JPG 
Views:	24 
Size:	24.7 KB 
ID:	48235



    Here's the full code. I didn't write any of this so I can't shed much light on it. There are other functions that contain the same syntax. Is there a library reference I need to select?
    Code:
    Public Function DeleteDuplicateSigEvent()
    Dim cmd1 As ADODB.Command
    Dim cmd2 As ADODB.Command
    Dim cmd3 As ADODB.Command
    Dim sSQL As String
    Dim sSQL1 As String
    Dim sSQL2 As String
    Dim sMsg As String
    Dim dtRD As Date
    Dim dtSigDt As Date
    Dim dtSigTm As Date
    Dim sShift As String
    Dim sTySig As String
    Dim sPatLN As String
    Dim sPatFN As String
    Dim sWd As String
    Dim sZeroShift As String
    Dim sOneShift As String
    Dim sTwoShift As String
    Dim sThreeShift As String
    Dim iCnt As Integer
    Dim iCnt1 As Integer
    Dim iCnt2 As Integer
    Dim bDupSig As Boolean
    Dim rsN As ADODB.Recordset
    Dim rsEmp As ADODB.Recordset
    
    
    ' DoCmd.Hourglass True
    sZeroShift = "0"
    sOneShift = "1"
    sTwoShift = "2"
    sThreeShift = "3"
    Set cmd1 = New ADODB.Command
    cmd1.ActiveConnection = CurrentProject.Connection
    cmd1.CommandType = adCmdText
    sSQL = "SELECT * FROM NewSigEvent WHERE Shift ='" & sZeroShift & "';"
    cmd1.CommandText = sSQL
    cmd1.Execute
    Set rsN = New ADODB.Recordset
    rsN.CursorType = adOpenDynamic
    rsN.LockType = adLockOptimistic
    rsN.Open cmd1
    iCnt = rsN.RecordCount
    If iCnt > 0 Then
       rsN.MoveFirst
       Do While Not rsN.EOF
          bDupSig = False
          dtSigDt = rsN.Fields("SigDate").Value
          dtSigTm = rsN.Fields("SigTime").Value
          sTySig = rsN.Fields("TypeSigEvent").Value
          sPatLN = rsN.Fields("PatLName").Value
          sPatFN = rsN.Fields("PatFName").Value
          Set cmd2 = New ADODB.Command
          cmd2.ActiveConnection = CurrentProject.Connection
          cmd2.CommandType = adCmdText
          sSQL = "SELECT * FROM NewSigEvent WHERE SigDate ='" & dtSigDt & "'" & "AND SigTime ='" & dtSigTm & "'" & "AND PatLName ='" & sPatLN & "'" & "AND PatFName ='" & sPatFN & "'" & "AND TypeSigEvent ='" & sTySig & "'" & "AND Shift ='" & sOneShift & "';"
          cmd2.CommandText = sSQL
          cmd2.Execute
          Set rsEmp = New ADODB.Recordset
          rsEmp.CursorType = adOpenDynamic
          rsEmp.LockType = adLockOptimistic
          rsEmp.Open cmd2
          iCnt = rsEmp.RecordCount
          If iCnt > 0 Then
             bDupSig = True
          End If
          rsEmp.Close
          Set rsEmp = Nothing
          Set cmd2 = Nothing
          Set cmd2 = New ADODB.Command
          cmd2.ActiveConnection = CurrentProject.Connection
          cmd2.CommandType = adCmdText
          sSQL = "SELECT * FROM NewSigEvent WHERE SigDate ='" & dtSigDt & "'" & "AND SigTime ='" & dtSigTm & "'" & "AND PatLName ='" & sPatLN & "'" & "AND PatFName ='" & sPatFN & "'" & "AND TypeSigEvent ='" & sTySig & "'" & "AND Shift ='" & sTwoShift & "';"
          cmd2.CommandText = sSQL
          cmd2.Execute
          Set rsEmp = New ADODB.Recordset
          rsEmp.CursorType = adOpenDynamic
          rsEmp.LockType = adLockOptimistic
          rsEmp.Open cmd2
          iCnt = rsEmp.RecordCount
          If iCnt > 0 Then
             bDupSig = True
          End If
          rsEmp.Close
          Set rsEmp = Nothing
          Set cmd2 = Nothing
          Set cmd2 = New ADODB.Command
          cmd2.ActiveConnection = CurrentProject.Connection
          cmd2.CommandType = adCmdText
          sSQL = "SELECT * FROM NewSigEvent WHERE SigDate ='" & dtSigDt & "'" & "AND SigTime ='" & dtSigTm & "'" & "AND PatLName ='" & sPatLN & "'" & "AND PatFName ='" & sPatFN & "'" & "AND TypeSigEvent ='" & sTySig & "'" & "AND Shift ='" & sThreeShift & "';"
          cmd2.CommandText = sSQL
          cmd2.Execute
          Set rsEmp = New ADODB.Recordset
          rsEmp.CursorType = adOpenDynamic
          rsEmp.LockType = adLockOptimistic
          rsEmp.Open cmd2
          iCnt = rsEmp.RecordCount
          If iCnt > 0 Then
             bDupSig = True
          End If
          rsEmp.Close
          Set rsEmp = Nothing
          Set cmd2 = Nothing
          If bDupSig = True Then
             rsN.Delete
          End If
          rsN.MoveNext
       Loop
    End If
    DoCmd.Hourglass False
    rsN.Close
    Set rsN = Nothing
    Set cmd1 = Nothing
    End Function
    As usual, Thanks in advance.

    Paul

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    you need to add the ADO library to your references

    Microsoft ADO Ext6

  3. #3
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Quote Originally Posted by CJ_London View Post
    you need to add the ADO library to your references

    Microsoft ADO Ext6
    I added this on and still received the same error. Was this the right one?

    Click image for larger version. 

Name:	Adp Conversion Project Error 2.JPG 
Views:	24 
Size:	22.4 KB 
ID:	48236


  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    should be, you should get intellisense one you have typed ADODB

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,421
    Fairly certain it is Microsoft ActiveX Data Objects #.# library
    My latest version is 6.1. I rarely have a need to use ADO. Regardless, if I add a library and I'm fairly certain that is the issue but it still won't compile, easy enough to remove the one that didn't help and try something else. Or I ask my friend Google...
    https://docs.microsoft.com/en-us/sql...l-server-ver16
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    Fairly certain it is Microsoft ActiveX Data Objects #.# library
    oops, think you are right - I always late bind so don't add references

  7. #7
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Quote Originally Posted by CJ_London View Post
    should be, you should get intellisense one you have typed ADODB
    Quote Originally Posted by Micron View Post
    Fairly certain it is Microsoft ActiveX Data Objects #.# library
    My latest version is 6.1. I rarely have a need to use ADO. Regardless, if I add a library and I'm fairly certain that is the issue but it still won't compile, easy enough to remove the one that didn't help and try something else. Or I ask my friend Google...
    https://docs.microsoft.com/en-us/sql...l-server-ver16
    Neither one of these references worked and no intellisense either.

  8. #8
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,421
    Code:
    Sub testReference()
    Dim cmd1 As ADODB.Command
    End Sub
    Compiles for me - and I get Intellisense. Make sure you didn't do what I often do - select the reference from the list and forget to check the box for it.
    Last edited by Micron; 07-06-2022 at 12:19 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Quote Originally Posted by Micron View Post
    Code:
    Sub testReference()
    Dim cmd1 As ADODB.Command
    End Sub
    Compiles for me - and I get Intellisense. Make sure you didn't do what I often do - select the reference from the list and forget to check the box for it.
    Doesn't work here. Not sure why. I've tried checking each one individually and both of them, but it does not compile on my end.

    Attachment 48240

  10. #10
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,421
    I get 'invalid attachment specified'.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Quote Originally Posted by Micron View Post
    I get 'invalid attachment specified'.
    Something went wrong when I posted my last comment.

    Click image for larger version. 

Name:	Adp Conversion Project Error Both.JPG 
Views:	20 
Size:	21.5 KB 
ID:	48242

  12. #12
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    maybe you have some corruption - create a new db and try a simple test there

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,552
    Perhaps compare references with the DB you imported from?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Quote Originally Posted by Welshgasman View Post
    Perhaps compare references with the DB you imported from?
    Winner, Winner, Chicken Dinner!

    It needed ActiveX Data Objects 2.1 Library

    Now I have intellisense, etc.

    This takes me a little further down the road. Now I have to rename all my tables. Fortunately I have a tool to do that.

    Thanks again,

    Paul

  15. #15
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    I thought I was in the clear, but something new popped up. Every event on my main form now returns the following error: Expected Identifier. Even the On Load Event.
    This was not happening on Friday, but I'm not aware of changing anything since then. In addition, I am unable to break the code to see what is causing it. This is all I get.

    Click image for larger version. 

Name:	Expected Identifier.JPG 
Views:	9 
Size:	28.8 KB 
ID:	48294

    I sort of feel like I am back to the drawing board. Here's the code for the On Load event in case that helps.
    Code:
    Private Sub Form_Load()
    
    bModSigEv = False
    bNSE = False
    Me.cmdSubmit.Visible = False
    Me.cmdSubmit1.Visible = False
    Me.cmdSubmit.Enabled = False
    Me.cmdSubmit1.Enabled = False
    
    End Sub
    Thanks in advance

    Paul H

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

Similar Threads

  1. Query statement conversion to string question
    By Euler271 in forum Queries
    Replies: 12
    Last Post: 06-25-2018, 10:54 AM
  2. Conversion to 64 bit Office - Access Question
    By mgilbert86 in forum Access
    Replies: 3
    Last Post: 10-26-2016, 09:36 AM
  3. PDF to JPG conversion
    By max_the_axe in forum Access
    Replies: 6
    Last Post: 09-01-2014, 11:33 AM
  4. MDE TO MDB conversion
    By cooglerj in forum Import/Export Data
    Replies: 2
    Last Post: 05-05-2014, 10:58 AM
  5. Unix TimeStamp Conversion Question
    By rmoreno in forum Queries
    Replies: 4
    Last Post: 06-26-2013, 09:52 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