Help with Error 6

ICAN

New member
Local time
Today, 06:03
Joined
Jul 25, 2013
Messages
5
Hello,

I am brand new to Access and need some help... I am now getting Error '6' for nearly every task I do, when these tasks were able to be completed priviously without issue. :confused: I would be so appreciative if anyone could direct me on how to correct this error.

Option Compare Database
Option Explicit
Private Sub Command5_Click()
DoCmd.Close
If (SysCmd(SYSCMD_GETOBJECTSTATE, A_FORM, "frmInvoice") = 1) Then 'form is open
Forms!frmInvoice!cmbJob.Requery
End If
End Sub
Private Sub Form_Activate()
Me.Requery
End Sub
Private Sub Form_Load()
'Me.RecordSource = Me.OpenArgs
End Sub
Private Sub ServID_DblClick(Cancel As Integer)
Dim intServid As Integer
If Not IsNull(ServID) Then
intServid = Val(ServID)
DoCmd.OpenForm "frmServiceOrder", OpenArgs:=intServid
End If
End Sub

Option Compare Database
Option Explicit
Private Sub cmdEditOrder_Click()
DoCmd.OpenForm "frmEditServiceOrder"
End Sub
Private Sub cmdAddOrder_Click()
DoCmd.OpenForm "frmServiceOrder"
End Sub
Private Sub cmdHelp_Click()
DoCmd.OpenForm "frmServiceOrderHelp"
End Sub
Private Sub cmdmfr_Click()
DoCmd.OpenForm "frmmfrs"
End Sub
Private Sub cmdContainerS_Click()
DoCmd.OpenForm "frmContainerMaster"
End Sub
Private Sub cmdTrucks_Click()
DoCmd.OpenForm "frmTruckMaster"
End Sub
Private Sub cmdJobsNotDone_Click()
DoCmd.OpenForm "frmjobsnotdone", OpenArgs:="select * from qryCustjoborders where reqservicedate is not null and servicedate is null order by ReqServiceDate"
End Sub
Private Sub cmdViewInv_Click()
If (SysCmd(SYSCMD_GETOBJECTSTATE, A_FORM, "frmContLocations") = 1) Then 'form is open
DoCmd.Close acForm, "frmContLocations"
Else
DoCmd.OpenForm "frmContLocations"
End If
End Sub
Private Sub Command116_Click()
DoCmd.OpenForm "frmPickListMenu"
End Sub
Private Sub Command117_Click()
DoCmd.OpenForm "frmUtilmenu"
End Sub
Private Sub Command121_Click()
DoCmd.OpenForm "frminvoice"
End Sub
Private Sub Command122_Click()
DoCmd.OpenForm "frmCustomers"
End Sub
Private Sub Command126_Click()
DoCmd.OpenForm "frmDrivers"
End Sub
Private Sub Command129_Click()
'DoCmd.OpenForm "frmPW", OpenArgs:=DLookup("pw", "tblpw", "[formname]='frmjob' ")
'Forms!frmPW!txtFormName = "frmjob"
DoCmd.OpenForm "frmjob"
End Sub
Private Sub Command131_Click()
DoCmd.OpenForm "frmJobHelp"
End Sub
Private Sub Command132_Click()
DoCmd.OpenForm "frmTrucks"
End Sub
Private Sub Command133_Click()
DoCmd.OpenForm "frmContainers"
End Sub
Private Sub Command134_Click()
DoCmd.OpenForm "frmInvoiceHelp"
End Sub
Private Sub Command136_Click()
DoCmd.OpenForm "frmLandfills"
End Sub
Private Sub Command144_Click()
DoCmd.OpenForm "frmjob", OpenArgs:="ExistCust"
End Sub
Private Sub Command147_Click()
DoCmd.OpenForm "frmUndoInvoice"
End Sub
Private Sub Command178_Click()
DoCmd.OpenForm "frmversion"
End Sub
Private Sub Command179_Click()
DoCmd.OpenForm "frmFinancialReps"
End Sub
Private Sub Command180_Click()
DoCmd.OpenForm "frmCustDatasheet"
End Sub
Private Sub Command56_Click()
DoCmd.OpenForm "frmServicereps"
End Sub
Private Sub Command63_Click()
DoCmd.Quit
End Sub
Private Sub Form_Activate()
Dim Frm As Form
Set Frm = Forms!frmMainMenu
Call RequeryCanTots(Frm)
End Sub
Private Sub TxtSO_Exit(Cancel As Integer)
Dim intServid As Integer
If Not IsNull(TxtSO) Then
intServid = Val(TxtSO)
If DCount("*", "tblserviceorders", "servid = " & intServid & " ") = 0 Then
MsgBox "No Such Order.", vbOKOnly, ""
TxtSO = Null
Exit Sub
End If
DoCmd.OpenForm "frmServiceOrder", OpenArgs:=intServid
Me!TxtSO = Null
End If
End Sub
 
So Access doesn't think you have a variable there, it might be wise to use the ME keyword and instead of the Not IsNull you can just use the NZ function.


intServid = CInt(Nz(Me.ServID,0))
 
Thank you for your prompt response. Unfortunately, that errored as well. Should I be looking somewhere else in the program for a solution?
 
Check your values by setting a break point and hit F8 to step through. Let me know if you don't know how to do that.
 
Click in the margin to the left of your code. Notice a red highlight covers the line and circle appears in the margin? Now run the code and notice it stops at that line with a yellow highlight? Now you are able to interrogate the values of your variables at this point in the execution of the code. Hover the mouse over variable. Also, open the locals window (menu->view->locals window) to see values of local variables. Open the watch window to add expressions or other variables you want evaluated.
 
You're defining intServid as an Integer, and the fact that the line

intServid = Val(ServID)

is popping Error 6, which is the error for Overflow, would suggest that using the Val() function against ServID (or more correctly, as Bob said, Me.ServID) is producing a number greater than 32767 which is the maximum for an Integer. Could that be the problem?

Linq ;0)>
 
You're defining intServid as an Integer, and the fact that the line

intServid = Val(ServID)

is popping Error 6, which is the error for Overflow, would suggest that using the Val() function against ServID (or more correctly, as Bob said, Me.ServID) is producing a number greater than 32767 which is the maximum for an Integer. Could that be the problem?

Linq ;0)>


YES. I think that is the problem. Can I redefine the maximum for an interger?
 
I hate to sound so simple, but I really am brand new to Access. How do I do that?
 
I hate to sound so simple, but I really am brand new to Access. How do I do that?

In your code:
Code:
Private Sub ServID_DblClick(Cancel As Integer)
Dim intServid As [B][COLOR=red]Long[/COLOR][/B]
If Not IsNull(ServID) Then
[COLOR=black]intServid = Val(ServID)[/COLOR]
DoCmd.OpenForm "frmServiceOrder", OpenArgs:=intServid
End If
End Sub
 
Additionally, I would change your variable name from intServid to lngServid just to keep it consistent with what the type is. Some people don't use the prefixes. I find they help me quickly identify something but it is important to pick a method and then be consistent with it.
 

Users who are viewing this thread

Back
Top Bottom