Adding New Record to a table

Acropolis

Registered User.
Local time
Today, 02:59
Joined
Feb 18, 2013
Messages
182
Hi, new here and new to access as well, so please forgive any stupid questions.

I have been trying to alter one of the templates in Access, issues and tasks.

So far I have done alright with it and managed to get it to do everything I have wanted, links to Outlook for email, appt's and tasks etc and thats all working fine.

I split the database today using the Access DB splitter, and then found out that datamacro's dont work once you have split the DB.

So I have set about sorting this out with code. I sorted the one to add comments and that is working absolutely fine. But the one to add a related issue I cannot get to work no matter what I try, it throws an error everytime.

This is the code I have done to bypass the datamacro, I have left out the part where it checks if the related item already exists as at the moment I am working with a blank set of records so it wont exist, it is something I need to put in, but wanted to get the main bit working first.

If I run the code without the On Error in there, it works and creates the entries in the RelatedIssue table, but when the On Error is on there, or when it runs from the macro on the form, it throws the error everytime.

I have tried err.descrption and it is blank.

Hope someone can help as I am pulling my hair out with this now (and I havent got much as it is!)

Code:
Public Function addrelateditemmain()
 Set rs = CurrentDb.OpenRecordset("SELECT * FROM RelatedIssues   ")
 On Error GoTo Errorhandler
   With rs
    .AddNew
    ![RelatedIssueID] = [TempVars]![tmpRelatedIssueID]
    ![IssueID] = [TempVars]![tmpIDR]
    .Update
    .Close
   End With
Errorhandler:
   MsgBox Err.Description
 Set rs = Nothing
End Function
 

Users who are viewing this thread

Back
Top Bottom