Page 2 of 2 FirstFirst 12
Results 16 to 27 of 27
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I do not know if it has something to do with the language, but cannot get any VBA code to run. Some of the embedded macros work and some error, but no VBA. Very odd, never encountered that before. Not sure I will be able to help.

    I tried to build an Access query to test the recordset code. Access cannot find table named [Προϊόντα].

    I do notice that the SQL statement in the code is missing the semi-colon (;) at the end. That might make a difference. Also, if the PrId parameter comes from the form, it needs to be concatenated into the sql.


    "[Προϊόντα].PrId = " & Me.Prid & ";", cnn1
    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.

  2. #17
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    Hi, seems to work if i put only one record (transactionline form).... but for multiply gives error

    myrecordset.MoveFirst
    lookupcheck = DLookup("[Apothema]", "Προϊόντα", "prid = " & Nz([Prid], 0))
    If lookupcheck < Forms![TransactionLine].Quantity Then
    MsgBox "Μη Επαρκές Υπόλοιπο, Το διαθέσιμο : " & lookupcheck & "", vbCritical, "Ανανέωσε την Αποθηκη σου"
    Else

    While Not (myrecordset.EOF)
    lookupcheck = DLookup("[Apothema]", "Προϊόντα", "prid = " & Nz([Prid], 0))
    myrecordset.Fields("apothema") = [lookupcheck] - [Quantity]
    myrecordset.Update
    myrecordset.MoveNext
    Wend
    MsgBox "Εγγραφές Ενημερώθηκαν", , "Εντολή Διάθεσης Υλικού"
    End If



    PS: for the table Προϊόντα if you select all tables, its the first, above the mainmenu form

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I am looking at all the tables. The table just above MainMenu is Υπόλογος. There is no Προϊόντα.

    Did you consider my suggestions about the SQL statement in the code?
    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.

  4. #19
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    The table is Προϊόντα (the form is products)

    I copied and pasted it here, i guess forum dont accept utf-8

    The prid comes from the table Προϊόντα.
    the transactionline.id is from the table transactionline

    I tried that but no work, gives error syntax join

  5. #20
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    Ok i guess its too difficult.
    What i manage to do is i can do update one by one. but i have to go to each record in the form and press the button

    Private Sub UpdateWareHouseButton_Click()
    Dim lookupcheck As Variant

    Dim cnn1 As ADODB.Connection
    Set cnn1 = CurrentProject.Connection
    Dim myrecordset As New ADODB.Recordset

    myrecordset.ActiveConnection = cnn1

    myrecordset.Open " SELECT * " & _
    " FROM [Products] INNER JOIN TransactionLine ON " & _
    "[Products].PrId = TransactionLine.Prid ", cnn1, adOpenKeyset, adLockOptimistic



    myrecordset.MoveFirst
    lookupcheck = DLookup("[Apothema]", "Προϊόντα", "prid = " & Nz([Prid], 0))
    If lookupcheck < Forms![TransactionLine].Quantity Then
    MsgBox "Μη Επαρκές Υπόλοιπο, Το διαθέσιμο : " & lookupcheck & "", vbCritical, "Ανανέωσε την Αποθηκη σου"
    Else

    myrecordset.Fields("apothema") = [lookupcheck] - [Quantity]
    myrecordset.Update
    myrecordset.MoveNext
    MsgBox "Records Updated", , "TransactionLine"
    End If
    myrecordset.Close
    Set myrecordset = Nothing
    Set cnn1 = Nothing
    End Sub

    --------------

    Is it possible to do this for all the records ? at once?

    Thanks

  6. #21
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    OK i have fixed it... and now works...

    Now updates all the records from the form

  7. #22
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    Is there any way for msgbox to appear the updated record?
    i used recordcounts but gives -1

    Do While Not myrecordset.EOF

    myrecordset.Fields("apothema") = [lookupcheck] - [Quantity]
    myrecordset.MoveNext
    Loop
    myrecordset.UpdateBatch
    MsgBox "total Records: " & CStr(myrecordset.RecordCount"",,"Update"

  8. #23
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Try the msgbox before the UpdateBatch. Syntax shown is wrong. Must be typos in the post because that should error.

    MsgBox "total Records: " & myrecordset.RecordCount, ,"Update"

    Congratulations on resolving the other issue.
    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. #24
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    no.. same result (-1)

  10. #25
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Try:

    myrecordset!apothema = Me.[lookupcheck] - Me.[Quantity]


    In this line "[Products].PrId = TransactionLine.Prid "
    TransactionLine.Prid looks like reference to a control on form. If it is it must be concatenated into the string, like:
    "[Products].PrId = " & TransactionLine.Prid
    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.

  11. #26
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    Sorry June7, im confused, cause deduct works , the recordcount dont work

    it gives me result -1

  12. #27
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Just dealt with this issue in my project. Had to change to adOpenStatic
    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.

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

Similar Threads

  1. Update records query...new to sql
    By hithere in forum Queries
    Replies: 6
    Last Post: 12-28-2011, 10:23 PM
  2. Update Multiple Records
    By anwaar in forum Programming
    Replies: 10
    Last Post: 09-02-2011, 05:16 PM
  3. Multiply front end on same computer?
    By efk0107 in forum Access
    Replies: 5
    Last Post: 01-25-2011, 08:39 AM
  4. How to Update 70,000++ Records
    By UCBFireCenter in forum Queries
    Replies: 54
    Last Post: 06-19-2009, 12:43 PM
  5. Replies: 3
    Last Post: 06-08-2009, 08:20 AM

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