Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    davideitaly is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    44

    Quote Originally Posted by June7 View Post
    What is TOTALE? A field or a variable? It is not a declared variable. Option Explicit requires all variables to be declared.

    Your contracts have extensive formatted boiler plate text? Hence the use of Word?
    TOTALE is again rubbish remained from the code I copied from another access forum. I tried to erase it but the automation always stops there, probably because WITH gets undeclared if I erase it.

    Yes, of course contracts are made almost totally of boilerplate text, the only changing parts are those I would like to take from the form: (lecturer's) name, surname address, ID number, followed by the course and subject(s) data. Name and surname are often repeated within the text.

  2. #17
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    You should be able to entirely delete TOTALE line or at least comment it with an apostrophe.
    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.

  3. #18
    davideitaly is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    44
    Quote Originally Posted by June7 View Post
    You should be able to entirely delete TOTALE line or at least comment it with an apostrophe.
    Ok, I did it and it runs, but the problem remains.

    If I change "recordset" with something else ("Rst"), it doesn't recognize the SQL and following:

    Click image for larger version. 

Name:	003.jpg 
Views:	11 
Size:	126.6 KB 
ID:	33382

    If I keep "Recordset", with "Recordset.Close" at the end of the code, when I get back to the form I have the usual blocked-unknown result.

    If I totally erase "Recordset.Close" at the end of the code, when I get back to the form I have as result only the record I printed and the other ones disappear, forcing me to close and re-open the form.

    I anyway kept at the top the additional "Option explicit", as suggested by Micron.

  4. #19
    davideitaly is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    44
    Ok, I solved myself.
    I just added at the end the instruction to re-open a recordset making reference to the main form-table:


    Code:
        ETC...
    
        Recordset.Close
    
        Wrd.Application.WordBasic.MsgBox "Esportazione terminata", "Esportazione dati da Access"
        
        Set Recordset = CurrentDb.OpenRecordset("Select * from Anagrafica_docenti")
    
    
    End Sub
    I would like to thank June7 for his precious support and Micron too.

    Thanks a lot indeed.

  5. #20
    davideitaly is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    44
    Hi guys. Sorry for re-open this thread but there's a new unexpected problem going on. With the code that seemed to work well:

    Code:
    SQL = "FROM Anagrafica_docenti INNER JOIN (Anagrafica_materie INNER JOIN (Anagrafica_corsi INNER JOIN Anagrafica_art_corsi ON Anagrafica_corsi.ID_Anagrafica_corsi = Anagrafica_art_corsi.CORSO) ON Anagrafica_materie.ID_anagmaterie = Anagrafica_art_corsi.MATERIA) ON Anagrafica_docenti.ID_Anagrafica_docenti = Anagrafica_art_corsi.ID_Anagrafica_docenti" & _"ORDER BY Anagrafica_art_corsi.DATA_CONTRATTO DESC , Anagrafica_art_corsi.PROTOCOLLO DESC;
    
    
    Set Recordset = CurrentDb.OpenRecordset("Select * from sqlbookmark WHERE ID_Anagrafica_docenti=" & Me.ID_Anagrafica_docenti & " AND Data_contratto=#" & DMax("Data_contratto", "sqlbookmark", "ID_Anagrafica_docenti=" & Me.ID_Anagrafica_docenti) & "#")
    it happens that some contract dates (DATA_CONTRATTO) result as "null", even if I typed them in.

    For instance, for the lecturer X, if I put dates from 26th March to 31th March, the automation populates the word model without any problem. With older or more recent dates, it stops at the DATA_CONTRATTO with the message: "invalid use of Null". But the field is not null!

    Is there any limitation that I can't see in the code that sets the recordset?

    Thank you.

  6. #21
    davideitaly is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    44
    Quote Originally Posted by davideitaly View Post
    Hi guys. Sorry for re-open this thread but there's a new unexpected problem going on. With the code that seemed to work well:

    Code:
    SQL = "FROM Anagrafica_docenti INNER JOIN (Anagrafica_materie INNER JOIN (Anagrafica_corsi INNER JOIN Anagrafica_art_corsi ON Anagrafica_corsi.ID_Anagrafica_corsi = Anagrafica_art_corsi.CORSO) ON Anagrafica_materie.ID_anagmaterie = Anagrafica_art_corsi.MATERIA) ON Anagrafica_docenti.ID_Anagrafica_docenti = Anagrafica_art_corsi.ID_Anagrafica_docenti" & _"ORDER BY Anagrafica_art_corsi.DATA_CONTRATTO DESC , Anagrafica_art_corsi.PROTOCOLLO DESC;
    
    
    Set Recordset = CurrentDb.OpenRecordset("Select * from sqlbookmark WHERE ID_Anagrafica_docenti=" & Me.ID_Anagrafica_docenti & " AND Data_contratto=#" & DMax("Data_contratto", "sqlbookmark", "ID_Anagrafica_docenti=" & Me.ID_Anagrafica_docenti) & "#")
    it happens that some contract dates (DATA_CONTRATTO) result as "null", even if I typed them in.

    For instance, for the lecturer X, if I put dates from 26th March to 31th March, the automation populates the word model without any problem. With older or more recent dates, it stops at the DATA_CONTRATTO with the message: "invalid use of Null". But the field is not null!

    Is there any limitation that I can't see in the code that sets the recordset?

    Thank you.

    Ok, did it: i correct the code this way:

    Code:
    Set Recordset = CurrentDb.OpenRecordset("Select * from sqlbookmark WHERE ID_Anagrafica_docenti=" & Me.ID_Anagrafica_docenti & " AND " & DMax("Data_contratto", "sqlbookmark", "ID_Anagrafica_docenti=" & Me.ID_Anagrafica_docenti))

  7. #22
    davideitaly is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    44
    Quote Originally Posted by davideitaly View Post
    Ok, did it: i correct the code this way:

    Code:
    Set Recordset = CurrentDb.OpenRecordset("Select * from sqlbookmark WHERE ID_Anagrafica_docenti=" & Me.ID_Anagrafica_docenti & " AND " & DMax("Data_contratto", "sqlbookmark", "ID_Anagrafica_docenti=" & Me.ID_Anagrafica_docenti))
    Nope... with this change, the code doesn't select the last contract date, but all the ones related to a lecturer.
    The problem remains. Need some urgent help, please!

  8. #23
    davideitaly is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    44
    I reply here my problem. Hope June, who provides the code, would help me...


    Quote Originally Posted by davideitaly View Post
    Hi guys. Sorry for re-open this thread but there's a new unexpected problem going on. With the code that seemed to work well:

    Code:
    SQL = "FROM Anagrafica_docenti INNER JOIN (Anagrafica_materie INNER JOIN (Anagrafica_corsi INNER JOIN Anagrafica_art_corsi ON Anagrafica_corsi.ID_Anagrafica_corsi = Anagrafica_art_corsi.CORSO) ON Anagrafica_materie.ID_anagmaterie = Anagrafica_art_corsi.MATERIA) ON Anagrafica_docenti.ID_Anagrafica_docenti = Anagrafica_art_corsi.ID_Anagrafica_docenti" & _"ORDER BY Anagrafica_art_corsi.DATA_CONTRATTO DESC , Anagrafica_art_corsi.PROTOCOLLO DESC;
    
    
    Set Recordset = CurrentDb.OpenRecordset("Select * from sqlbookmark WHERE ID_Anagrafica_docenti=" & Me.ID_Anagrafica_docenti & " AND Data_contratto=#" & DMax("Data_contratto", "sqlbookmark", "ID_Anagrafica_docenti=" & Me.ID_Anagrafica_docenti) & "#")
    it happens that some contract dates (DATA_CONTRATTO) result as "null", even if I typed them in.

    For instance, for the lecturer X, if I put dates from 26th March to 31th March, the automation populates the word model without any problem. With older or more recent dates, it stops at the DATA_CONTRATTO with the message: "invalid use of Null". But the field is not null!

    Is there any limitation that I can't see in the code that sets the recordset?

    Thank you.

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

Similar Threads

  1. Cycle through variables
    By Ruegen in forum Programming
    Replies: 9
    Last Post: 11-20-2014, 08:50 PM
  2. Cycle through collection
    By Ruegen in forum Programming
    Replies: 2
    Last Post: 11-19-2014, 04:50 PM
  3. Cycle Through Parameters in VBA
    By kestefon in forum Access
    Replies: 3
    Last Post: 07-10-2014, 02:27 PM
  4. Recordset cycle problem
    By free_style in forum Programming
    Replies: 3
    Last Post: 08-25-2011, 02:44 PM
  5. Cycle Time
    By Dargo in forum Forms
    Replies: 5
    Last Post: 02-26-2009, 05:14 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