Inserting subform/Table data into specific fields in Excel (1 Viewer)

Sam Summers

Registered User.
Local time
Today, 09:41
Joined
Sep 17, 2001
Messages
939
Your code shows MsgBox Error$ in the error handler, which suggests the error handler isn't being reached.
Perhaps the error is in Excel rather than Access?

Try changing that line to:
Code:
MsgBox "Error " & Err.Number & " in SaveAndNewBtn_Click procedure: " & Err.Description

What error message do you see now?

I've downloaded your file but have no idea which button to click to trigger this behaviour
I don't have time to look at your db properly now but suggest you tell us what exactly to do for the error to occur
Help us to help you
Tried that and now I get the message attached.

I'll take another look with the debugger
 

Attachments

  • Screenshot 2022-07-05 133020.png
    Screenshot 2022-07-05 133020.png
    13.5 KB · Views: 99

KitaYama

Well-known member
Local time
Today, 17:41
Joined
Jan 6, 2022
Messages
1,540
oBook
oSheet(Me.SelectedFile).Offset(0, 5).Value.CopyFromRecordset rs 'Copy recs to sheet
  • rs is empty. You haven't set it yet.
  • Offset should be set against a range not a sheet. oSheet.Range("A1").Offset(0,5)
  • the first line (oBook). You can't use an object like this.
  • As advised by @June7 Disable error handler for debugging. Only implement after code works properly.
  • While testing, don't set warning to false (DoCmd.SetWarnings False)
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:41
Joined
Sep 21, 2011
Messages
14,253
Walk through your code line by line. That will tell you what line is causing the error.
 

Users who are viewing this thread

Top Bottom