Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open recordset

Status
Not open for further replies.

mgbeye

Programmer
May 30, 2001
47
US
I am trying to update two tables from the code of a form. When the button is clicked I would like the information to be copied to these tables. Here is the code I have so far. Can anyone make some suggestions as to why I am still getting errors?

Code:
Option Compare Database
Option Explicit
Private Sub Calculate_Click()
On Error GoTo Err_Calculate_Click

Dim varANS As Boolean
Dim dbsBlowMold As Database
Dim rstProductionReporting As Recordset
Dim rstProductionRecords As Recordset

DoCmd.RunMacro "Open Subtotals"

Set dbsBlowMold = OpenDatabase("C:\Melissa\Blowmold.mdb")
Set rstProductionRecords = dbsBlowMold.OpenRecordset("Production Records")
Set rstProductionReporting = dbsBlowMold.OpenRecordset("Production Reporting Table")

Do Until rstProductionReporting.[EOF]
    If rstProductionRecords.Material= Me.Material And rstProductionRecords.Mvt = Me.Mvt And rstProductionRecords.post_date = Me.[Post date] And rstProductionRecords.Quantity = Me.Quantity Then
        varANS = Msgbox("This action will creat duplicate records.@Continue?", vbYesNo, varANS = True)
        If varANS = True Then
          With rstProductionRecords
            .AddNew
            .Mvt = Me.Mvt
            .Material = Me.Material
            .Old_Matl = Me.[Old matl]
            .Material_desc = Me.[Material desc]
            .post_date = Me.[Post date]
            .Quantity = Me.Quantity
            .Update
           End With
        End If
    Else
         With rstProductionRecords
            .AddNew
            .Mvt = Me.Mvt
            .Material = Me.Material
            .Old_Matl = Me.[Old matl]
            .Material_desc = Me.[Material desc]
            .post_date = Me.[Post date]
            .Quantity = Me.Quantity
            .Update
           End With
    End If
    
Exit_Calculate_Click:
    Exit Sub

Err_Calculate_Click:
    Msgbox Err.Description
    Resume Exit_Calculate_Click
Loop

End Sub
[\code]

The error message says: "Method or Mode not found." 
Any suggestions??
 
By just looking at things, I've never seen:

rstProductionReporting.[EOF]

I think this might cause a problem since it is a method not a field.

Hope this helps,
Bill N
 
Hi nyteiz

My first impression is that the loop is incorrect at the end. Your error handling routine in INSIDE the loop.

It should be:-

Loop

Exit_Calculate_Click:
Exit Sub

Err_Calculate_Click:
Msgbox Err.Description
Resume Exit_Calculate_Click


End Sub

Try this and see if it works.

*
***
*****
*******
Ziggurat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top