Page 3 of 3 FirstFirst 123
Results 31 to 39 of 39
  1. #31
    g.adamo@email.it is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    18
    I'm not sure I understand



    what and how I have to do?

  2. #32
    g.adamo@email.it is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    18
    orderSQL = "desc"
    greatless = "<"
    mysql = "SELECT TOP 1 updateallresults.values" _
    & " FROM updateallresults" _
    & " WHERE (((updateallresults.checkpoint)=" & checkptsql & ") AND ((updateallresults.system)=" & Chr(34) & sysSQL & Chr(34) & ") AND ((updateallresults.tilt)" & greatless & rs.Fields("tilt") & ") and ((IsNull([values]))=False) AND ((updateallresults.values)<>0))" _
    & " ORDER BY updateallresults.tilt " & orderSQL & ";"
    ' Debug.Print mysql & "here"

    Set rst = CurrentDb.OpenRecordset(mysql)
    If rst.EOF Then
    completed = False
    Else: updateval = rst.Fields(0)
    completed = True
    End If





    End If














    on debug:




    sqlstring = "UPDATE tbltilt_full SET tbltilt_full.[values] =" & updateval & " WHERE (([tbltilt_full].[code]=" & Chr(34) & rs.Fields("code") & Chr(34) & "));"


    Debug.Print i & " " & sqlstring


    CurrentDb.Execute (sqlstring)
    rs.MoveNext
    i = i + 1
    Loop

  3. #33
    g.adamo@email.it is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    18

    all

    Option Explicit
    Option Compare Database

    Private Sub Command0_Click()
    Dim rst As dao.Recordset
    Dim db As Database
    Dim rs As dao.Recordset
    Set db = CurrentDb
    Dim i As Integer
    i = 0
    Dim checkptsql As Integer
    Dim sysSQL As String
    Dim orderSQL As String
    Dim greatless As String
    Dim mysql As String
    Dim updateval As Variant
    updateval = 0
    Dim completed As Boolean


    Set rs = db.OpenRecordset("updateallresults")
    Dim sqlstring As String


    Do While Not rs.EOF
    completed = False
    Select Case IsNull(rs.Fields("values")) Or rs.Fields("values") = 0
    Case Is = False
    updateval = rs.Fields("values")
    completed = True

    Case Is = True

    checkptsql = rs.Fields("checkpoint")
    sysSQL = rs.Fields("system")
    orderSQL = "Asc"
    greatless = ">"
    mysql = "SELECT TOP 1 updateallresults.values" _
    & " FROm updateallresults" _
    & " WHERE (((updateallresults.checkpoint)=" & checkptsql & ") AND ((updateallresults.system)=" & Chr(34) & sysSQL & Chr(34) & ") AND ((updateallresults.tilt)" & greatless & rs.Fields("tilt") & ") and ((IsNull([values]))=False) AND ((updateallresults.values)<>0))" _
    & " ORDER BY updateallresults.tilT " & orderSQL & ";"
    'Debug.Print mysql

    Set rst = CurrentDb.OpenRecordset(mysql)

    If rst.EOF Then
    completed = False



    Else: updateval = rst.Fields(0)
    completed = True

    End If

    End Select






    If completed = False Then



    orderSQL = "desc"
    greatless = "<"
    mysql = "SELECT TOP 1 updateallresults.values" _
    & " FROM updateallresults" _
    & " WHERE (((updateallresults.checkpoint)=" & checkptsql & ") AND ((updateallresults.system)=" & Chr(34) & sysSQL & Chr(34) & ") AND ((updateallresults.tilt)" & greatless & rs.Fields("tilt") & ") and ((IsNull([values]))=False) AND ((updateallresults.values)<>0))" _
    & " ORDER BY updateallresults.tilt " & orderSQL & ";"
    ' Debug.Print mysql & "here"

    Set rst = CurrentDb.OpenRecordset(mysql)
    If rst.EOF Then
    completed = False
    Else: updateval = rst.Fields(0)
    completed = True
    End If





    End If



















    sqlstring = "UPDATE tbltilt_full SET tbltilt_full.[values] =" & updateval & " WHERE (([tbltilt_full].[code]=" & Chr(34) & rs.Fields("code") & Chr(34) & "));"


    Debug.Print i & " " & sqlstring


    CurrentDb.Execute (sqlstring)
    rs.MoveNext
    i = i + 1
    Loop






















    rs.Close

    Set rs = Nothing
    rst.Close


    Set rst = Nothing











    End Sub



    Private Sub Command6_Click()
    Dim checks As Integer
    Dim tilts As Integer
    Dim check As Integer
    Dim i, j As Integer
    Dim systemlist As String
    Dim systems As Integer
    Dim syst() As String
    Dim numbers As Variant
    Dim db As Database
    Set db = CurrentDb
    Dim mysql As String
    Dim rs As Recordset
    Set rs = db.OpenRecordset("qrydistincttilts")
    systems = rs.RecordCount
    Do Until rs.EOF
    systemlist = systemlist & rs.Fields("system") & ","
    rs.MoveNext
    Loop
    Debug.Print systemlist


    DoCmd.SetWarnings False
    DoCmd.RunSQL "DELETE * FROM tbltilt_full"
    DoCmd.SetWarnings True


    checks = DMax("[checkpoint]", "tbltilt")
    tilts = DMax("[tilt]", "tbltilt")

    syst = Split(systemlist, ",")
    For check = 1 To checks
    For i = 1 To systems



    For j = 0 To tilts
    mysql = "insert into tbltilt_full (checkpoint,system,tilt)" _
    & " values (" & check & "," & Chr(34) & syst(i - 1) & Chr(34) & "," & j & ");"
    'Debug.Print mysql



    db.Execute (mysql)
    Next
    Next
    Next



    End Sub

  4. #34
    g.adamo@email.it is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    18
    Cartel1.zip
    I attached a file input that contains max values (checkpoint 1-10; system 1-10; tilt 0-10. exploding sum with condition this file have to produce more than one 1000 rows, the result may be 10*10*11)

  5. #35
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    confused.com

    valueswithconditionv5.zip

    If I import your data into tbltilt using the ExternalData (excel) wizard this works perfectly

  6. #36
    g.adamo@email.it is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    18
    ummumum
    if I import excell (wizard) when I push the second button the same error appears:
    on local window
    4OF04871 CALTAGIRONE OVEST 1° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 10° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 2° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 3° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 4° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 5° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 6° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 7° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 8° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 9° GSMVODAFONE,
    0 UPDATE tbltilt_full SET tbltilt_full.[varvalues] =0,157 WHERE (([tbltilt_full].[varcode]="64OF04871 CALTAGIRONE OVEST 5° GSMVODAFONE10"));

  7. #37
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Where is that comma coming from? 0,157??


    Sent from my iPhone using Tapatalk

  8. #38
    g.adamo@email.it is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    18
    on the new tbltilt the record 0,157 fisrt time appears on the row 91

    I imported excell on tbltilt then I press first botton .
    ok
    then I press second botton and the same error appear "error run time 3144...." Iclose the error window press alt+11 then ctrl+g amd on local window appears:
    4OF04871 CALTAGIRONE OVEST 1° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 10° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 2° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 3° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 4° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 5° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 6° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 7° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 8° GSMVODAFONE,4OF04871 CALTAGIRONE OVEST 9° GSMVODAFONE,
    0 UPDATE tbltilt_full SET tbltilt_full.[varvalues] =0,157 WHERE (([tbltilt_full].[varcode]="64OF04871 CALTAGIRONE OVEST 5° GSMVODAFONE10"));

  9. #39
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    SQL hates commas?

    valueswithconditionv51.zip


    Well I think this should do the job.

    I replicated your error on my PC by changing my local settings to show a comma in a decimal number. (SQL hates 0,04 I presume!!)


    The error no longer happens as I've replaced the comma with a "." in the SQL update statement

    Fingers crossed!!

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Add second where condition
    By tagteam in forum Access
    Replies: 4
    Last Post: 03-22-2016, 03:46 PM
  2. Spread values ​​by date in query
    By arn0ldas in forum Access
    Replies: 2
    Last Post: 12-15-2015, 04:23 AM
  3. Replies: 6
    Last Post: 02-25-2014, 12:48 AM
  4. Replies: 4
    Last Post: 11-19-2013, 06:53 PM
  5. Replies: 1
    Last Post: 12-14-2010, 10:03 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