View Full Version : XP Developer Executable Program Gives Runtime Error


tybeedi
02-25-2009, 01:30 PM
Can anyone help me with the below code problem? I added the below code to the after update event of my login form to check to make sure there are no blank records in my agency number lookup table. When I compile the program, I now get a runtime error when running the program on desktops that do not have MS Access. If I take out the do until/with and don't update each record in the table with the agency number then the code runs fine so it is something that MS Access XP Developer Packinging Wizard doesn't like. The Packinging Wizard is for Version 2003. Any help would be appreciated. I really wanted to use a session variable to store the agency number but it was unreliable so I opted for the single record (I thought) in a lookup table and am also having problems with it, obviously.

Private Sub txtAgencyPassword_AfterUpdate()
If Me.txtAgencyPassword <> Me.cboAgencyName.Column(1) Then
DoCmd.Beep
MsgBox "The password you entered is INCORRECT. Please try again."
Forms!frmLogin!txtAgencyPassword.SetFocus
Else
xAgency = cboAgencyName.Column(2)
Dim ESPReportingSystem As DAO.Database
Dim RSStoreAgency As DAO.Recordset
Dim strSQL As String
Dim intI As Integer

On Error GoTo ErrorHandler

Set ESPReportingSystem = CurrentDb
strSQL = "SELECT * FROM tblStoreAgencyNumber"
Set RSStoreAgency = ESPReportingSystem.OpenRecordset(strSQL, dbOpenDynaset)
If RSStoreAgency.EOF Then Exit Sub

With RSStoreAgency
Do Until RSStoreAgency.EOF
.Edit
![AgencyNumber] = xAgency
.Update
.MoveNext

Loop
End With
RSStoreAgency.Close
Set RSStoreAgency = Nothing
Set ESPReportingSystem = Nothing
DoCmd.OpenForm "Switchboard"

ErrorHandler:
If Err.Number > 0 Then
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End If
End If
End Sub

DCrake
02-26-2009, 12:01 AM
If you take out the With RSStoreAgency /End with lines and trry it again. I don't think you need them. I say that because I don't use them.

With RSStoreAgency
Do Until RSStoreAgency.EOF
.Edit
![AgencyNumber] = xAgency
.Update
.MoveNext

Loop
End With


Do Until RSStoreAgency.EOF
RSStoreAgency.Edit
RSStoreAgency("AgencyNumber") = xAgency
RSStoreAgency.Update
RSStoreAgency.MoveNext
Loop


David