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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

runtime error 2448

Status
Not open for further replies.

sparkbyte

Technical User
Sep 20, 2002
879
US
I am trying to track down why I am getting the error intermittently.


The 2 spots that the degger show are highlighted in the code.

This DB was inherited with my new job!

Table:
TrackingTable
Columns:
Tracking_ID / PK
BoxNumber / text
FileNumber / text
TrackingDate / Date/Time

The entry for is a simple Wizard created 3 field scrolling entry form.

The application has no modules. All VBA is within the FORM.

Code:
Option Compare Database
Option Explicit

Private Sub Text4_DblClick(Cancel As Integer)
End Sub
Private Sub BoxNumber_AfterUpdate()
Me.BoxNumber.DefaultValue = """" & Me.BoxNumber & """"
End Sub

Private Sub FileNumber_Enter():
[highlight]TrackingDate = Now()[/highlight]

'If Not Me.NewRecord Then    -  not working, redundant, adding to current not next box number
'Me.BoxNumber = "Me.BoxNumber.DefaultValue"
'End If

'strBoxTemp = "Me.BoxNumber"
'Dim strBoxTemp As String
'Me.BoxNumber = strBoxTemp
'FileNumber.SetFocus     - after get tracking number to save & post uncomment this if nec

'strBoxTemp = "Me.BoxNumber" moves current box number to temp in after update box
'Me.BoxNumber.DefaultValue = "strBoxTemp"
'Me.BoxNumber = "strBoxTemp" moves literal 'strBoxTemp' into current box number field
'Me.BoxNumber = strBoxTemp - gets error, can't be zero length string TrackingTable.BoxNumber
'Me.BoxNumber = strBoxTemp

End Sub

Private Sub FileNumber_Exit(Cancel As Integer)
'TrackingDate = Now()
'DoCmd.GoToRecord , , acNewRec
'FileNumber.SetFocus
End Sub

Private Sub Form_Load():
    DoCmd.GoToRecord , , acNewRec
    BoxNumber.SetFocus
    [highlight]TrackingDate = Now()[/highlight]
End Sub

Private Sub NewTrackingNumber_Click()
On Error GoTo Err_NewTrackingNumber_Click
Dim EnvString, Indx, Msg, envLen   ' Declare variables.
'DoCmd.Close acForm, , acSaveYes
'move something to file number  here
FileNumber = ".box.end."

    DoCmd.OpenForm "TrackingTable", acNormal
    
    DoCmd.GoToRecord , , acNewRec
    BoxNumber.SetFocus
    
Exit_NewTrackingNumber_Click:
    Exit Sub

Err_NewTrackingNumber_Click:
    MsgBox Err.Description
    Resume Exit_NewTrackingNumber_Click
    
End Sub

Private Sub PreviousTrackingNumber_Click()
On Error GoTo Err_PreviousTrackingNumber_Click

    DoCmd.GoToRecord , , acPrevious

Exit_PreviousTrackingNumber_Click:
    Exit Sub

Err_PreviousTrackingNumber_Click:
    MsgBox Err.Description
    Resume Exit_PreviousTrackingNumber_Click
    
End Sub
Private Sub Print_Click()
On Error GoTo Err_Print_Click

    Dim stDocName As String
    Dim MyForm As Form

    stDocName = "TrackingTable1"
    Set MyForm = Screen.ActiveForm
    DoCmd.SelectObject acForm, stDocName, True
    DoCmd.PrintOut
    DoCmd.SelectObject acForm, MyForm.Name, False

Exit_Print_Click:
    Exit Sub

Err_Print_Click:
    MsgBox Err.Description
    Resume Exit_Print_Click
    
End Sub
Private Sub Close_Form_Click()
On Error GoTo Err_Close_Form_Click

    DoCmd.Close

Exit_Close_Form_Click:
    Exit Sub

Err_Close_Form_Click:
    MsgBox Err.Description
    Resume Exit_Close_Form_Click
    
End Sub

Thanks

John Fuhrman
 


Hi,

TrackingDate is undefined AND you have Oprion Explicit. You must declare TrackingDate.

also

TrackingDate = Now

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Have you tried this ?
[!]Me![/!]TrackingDate = Now()

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Nope, overlooking the obvious, Thanks PH



Thanks

John Fuhrman
 




Please post MS Access questions in one of the many MS Access forums like
forum702
forum705
forum701
forum703
forum700
forum181

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Cleaned the unneeded colons from the FORM VBA.

OK, here is the VBA.

Code:
Option Compare Database
Option Explicit
'On Error Resume Next

Private Sub BoxNumber_AfterUpdate()
Me.BoxNumber.DefaultValue = """" & Me.BoxNumber & """"
End Sub

Private Sub FileNumber_Enter()
Dim TrackingDate As Date

Me.TrackingDate = Now

'If Not Me.NewRecord Then    -  not working, redundant, adding to current not next box number
'Me.BoxNumber = "Me.BoxNumber.DefaultValue"
'End If

'strBoxTemp = "Me.BoxNumber"
'Dim strBoxTemp As String
'Me.BoxNumber = strBoxTemp
'FileNumber.SetFocus     - after get tracking number to save & post uncomment this if nec

'strBoxTemp = "Me.BoxNumber" moves current box number to temp in after update box
'Me.BoxNumber.DefaultValue = "strBoxTemp"
'Me.BoxNumber = "strBoxTemp" moves literal 'strBoxTemp' into current box number field
'Me.BoxNumber = strBoxTemp - gets error, can't be zero length string TrackingTable.BoxNumber
'Me.BoxNumber = strBoxTemp

End Sub

Private Sub FileNumber_Exit(Cancel As Integer)
'Me.TrackingDate = Now()
'DoCmd.GoToRecord , , acNewRec
'Me.FileNumber.SetFocus
End Sub

Private Sub Form_Load()
Dim TrackingDate As Date

    DoCmd.GoToRecord , , acNewRec
    Me.TrackingDate = Now
    Me.BoxNumber.SetFocus
End Sub

Private Sub NewTrackingNumber_Click()

On Error GoTo Err_NewTrackingNumber_Click

Dim EnvString, Indx, Msg, envLen   ' Declare variables.
'DoCmd.Close acForm, , acSaveYes
'move something to file number  here

FileNumber = ".box.end."
    DoCmd.OpenForm "TrackingTable", acNormal
    DoCmd.GoToRecord , , acNewRec
    Me.BoxNumber.SetFocus
Exit_NewTrackingNumber_Click:
    Exit Sub
Err_NewTrackingNumber_Click:
    MsgBox Err.Description
    Resume Exit_NewTrackingNumber_Click
End Sub

Private Sub PreviousTrackingNumber_Click()
On Error GoTo Err_PreviousTrackingNumber_Click
    DoCmd.GoToRecord , , acPrevious
Exit_PreviousTrackingNumber_Click:
    Exit Sub
Err_PreviousTrackingNumber_Click:
    MsgBox Err.Description
    Resume Exit_PreviousTrackingNumber_Click
End Sub
Private Sub Print_Click()
    Dim stDocName As String
    Dim MyForm As Form

On Error GoTo Err_Print_Click
    
    stDocName = "TrackingTable"
    Set MyForm = Screen.ActiveForm
    DoCmd.SelectObject acForm, stDocName, True
'    DoCmd.PrintOut
'    DoCmd.RunCommand acCmdPrint
    DoCmd.RunCommand acCmdPrintPreview
    DoCmd.SelectObject acForm, MyForm.Name, False

Exit_Print_Click:
    Exit Sub
Err_Print_Click:
    MsgBox Err.Description
    Resume Exit_Print_Click
End Sub

Private Sub Close_Form_Click()

On Error GoTo Err_Close_Form_Click
   DoCmd.Close
Exit_Close_Form_Click:
    Exit Sub
Err_Close_Form_Click:
    MsgBox Err.Description
    Resume Exit_Close_Form_Click
End Sub

Private Sub Form_Timer()
    Me.lblClock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm AMPM")
End Sub

Thanks

John Fuhrman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top