I'm having problems with this code and I'm getting the massage "Method or Database not found” I’m a newbie to VBA so any help would be great. Thanks
Code:
Option Compare Database
Option Explicit
Private Sub Calc_Click()
Dim dbs As DAO.Databases
Dim rst As DAO.Recordset
Dim wtb As Integer
Dim r As Integer
Dim sr As Integer
Dim x As Integer
Dim y As Integer
Dim w As Integer
Dim th As Integer
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("weektbl", dbOpenDynaset)
wtb = Format(Me.DesignComplete(), "ww") - Format(Me.ReadyToSample(), "ww")
Me.WeekToBuild = wtb
r = Me.TotalHr / Me.WeekToBuild
sr = Format(Me.ReadyToSample(), "ww")
Me.WeekNum = sr
Me.Result = r
Me.AutoIDTool
x = Format(Me.ReadyToSample(), "ww")
y = wtb + x
w = Format(Me.DesignComplete(), "ww")
th = Me.TotalHr / wtb
y = wtb + w
For x = w To y
If x < y Then
rst.AddNew
rst("WeekNum") = x
rst("JobHr") = th
rst.Update
rst.NextRecordset
End If
Next x
End Sub