Object Required - Linked Table (1 Viewer)

Drand

Registered User.
Local time
Today, 15:46
Joined
Jun 8, 2019
Messages
179
Hi

I have a back end on another computer which in the main works fine. I have however one linked table which I cannot update.

My function is

Code:
Public Function AddToGSTAccount()
Dim dbsPaymentsDue As Database

 Set dbsPaymentsDue = CurrentDb
  Set rstTblPaymentsDue = dbsPaymentsDue.OpenRecordset("TblPaymentsDue")
 
   rstTblPaymentsDue.AddNew
   rstTblPaymentsDue!DateAdded = Now()
   rstTblPaymentsDue!Payee = Forms!FrmAddNewPaymentDue.cboPayee
   rstTblPaymentsDue!Description = Forms!FrmAddNewPaymentDue.cboPaymentFor
   rstTblPaymentsDue!Amount = Forms!FrmAddNewPaymentDue.txtAmount
   rstTblPaymentsDue!DateDue = Forms!FrmAddNewPaymentDue.txtDateDue
   rstTblPaymentsDue.Update
  

 Set rstTblGST = dbsPaymentsDue.OpenRecordset("TblGST")
 
 rst.TblGST.AddNew
 rst.TblGST!TransDate = Date
 rst.TblGST!Deposit = Forms!FrmAddNewPaymentDue.txtAmount
 rst.TblGST.Update
  

End Function

The table "tblPaymentsDue" updates but I get the "object required" error when the code runs to the "tblGST" part.

Any assistance would be appreciated.

Thanks
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:46
Joined
Feb 19, 2002
Messages
43,352
Do you have Option Explicit specified? If not you should. It looks like your set statement uses rstTblGST but the rest of the code uses rst.TblGST
 

Drand

Registered User.
Local time
Today, 15:46
Joined
Jun 8, 2019
Messages
179
Thank you. It was the dot in rst.tblgst that was the issue. My bad!
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:46
Joined
Feb 19, 2002
Messages
43,352
Did you add Option Explicit? You would have gotten a compile error. It is always better to get errors at compile time than at run time. Set the property to require variable definition, and manually add the Option Explicit to any existing modules that don't have it because it wasn't set initially.
 

Users who are viewing this thread

Top Bottom