Run-time Error "2450"

essence

Registered User.
Local time
Today, 12:58
Joined
Nov 20, 2006
Messages
21
Firstly, I must say thanks for the sample databases. I am using code from one of them to display project images in a database. However, I am getting the run-time error "2450" - Microsoft Access can't find the form "frmPictureExample" referred to in a macro expression or visual basic code. When I click debug, the error appears to be on this code:

Private Sub Form_Load()
OrigHght = Forms!frmPictureExample!picsubform![imgPicture].Height
OrigWdth = Forms!frmPictureExample!picsubform![imgPicture].Width

End Sub

which is located on the subform "frmPictureExample" which is within the main form "frmEditProjects"

I tried moving that code and place it on the Load event on the main form but I get a 'No current record' error.

Help please!
 
"Not finding the form" can mean that the form isn't open, and that may be your problem here; at this point in your loading the form hasn't been loaded. Try moving it to the Sub Form_Current().
 
Also, remember subform syntax:

Forms!frmPictureExample!picsubform.Form![imgPicture].Width

And make sure picsubform is actually the name of the subform container that contains the subform on the main form.
 
I tried both but I'm still getting the error message. I have no code on the OnCurrent and On Load event of the main form, "frmEditProjects". On the subform "frmPictureExample", I have the stated code on the onload event and on the oncurrent event, here is the code:

Private Sub Form_Current()
On Error GoTo HandleErr


Me.RecordsetClone.MoveLast

If (Me.RecordsetClone.RecordCount) < 1.5 Then
Me.cmdNext.Enabled = False
Me.cmdPrevious.Enabled = False

ElseIf Me.RecordsetClone.RecordCount = Me.CurrentRecord Then
Me.cmdNext.Enabled = False
Me.cmdPrevious.Enabled = True

ElseIf Me.CurrentRecord = 1 Then
Me.cmdNext.Enabled = True
Me.cmdPrevious.Enabled = False

Else
Me.cmdNext.Enabled = True
Me.cmdPrevious.Enabled = True

End If

If Not IsNull([img_text]) Then
Forms!frmPictureExample!picsubform![imgPicture].Picture = [img_text]
SysCmd acSysCmdSetStatus, "Image: '" & [img_text] & "'."
Else
Forms!frmPictureExample!picsubform![imgPicture].Picture = ""
SysCmd acSysCmdClearStatus
End If
Exit Sub

HandleErr:
If Err = 2220 Then
Forms!frmPictureExample!picsubform![imgPicture].Picture = ""
SysCmd acSysCmdSetStatus, "Can't open image: '" & [img_text] & "'"
Else
MsgBox Err.Description, vbExclamation
End If

End Sub

Should I move these codes to the main form?
 
Ok, I'll try again, ensuring that the syntax follows what you wrote.
 

Users who are viewing this thread

Back
Top Bottom