Hi,
I am trying to write a global or multi-purpose function that will refresh or requery (what ever the correct term is) a form to reflect the updated record. The form contains normal data and has one field that displays a jpeg image (saved outside of the db as a link). I have various event procedures that happen when a form is opened or a record selected depending if a jpeg has been associated with a record or not.
If the record does have a jpeg then certain fields are displayed and others hidden.
If the record does *not* have an associated jpeg then certain other fields are displayed and others hidden.
I have a cmd button that calls a set of functions (developed by Candace Tripp) that allows a user to select a new image to add to the record.
It is at this point that I would like to call the form refresh or requery function, so that the newly added jpeg would trip the hide/display criteria that changes the fields displayed.
I have tried various methods and event commands and none seem to work.
I have written a module but when I add a new image and the fuction is called, Access gives me an "Object does not support this property or method" error. I have included my function code below. At the moment the function is called at the end of the command button's "on click" event.
Any suggestions would be great as I am totally stumped.
My grateful thanks in advance
Kenny
--------------------------Code begins-------------------
Option Compare Database
Function RequeryFrm()
If Trim(Nz(txtPicture, "")) = "" Then
[Forms]![frmPlant_Main].[Form]![Garden_Sub].Image1.Visible = False
[Forms]![frmPlant_Main].[Form]![Garden_Sub].txtPicture.Visible = True
[Forms]![frmPlant_Main].[Form]![Garden_Sub].cmdBrowse.Visible = True
Else
[Forms]![frmPlant_Main].[Form]![Garden_Sub].Image1.Visible = True
[Forms]![frmPlant_Main].[Form]![Garden_Sub].txtPicture.Visible = False
[Forms]![frmPlant_Main].[Form]![Garden_Sub].cmdBrowse.Visible = False
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
RequeryFrm_Exit:
Exit Function
RequeryFrm_Err:
MsgBox Error$
Resume RequeryFrm_Exit
End Function
I am trying to write a global or multi-purpose function that will refresh or requery (what ever the correct term is) a form to reflect the updated record. The form contains normal data and has one field that displays a jpeg image (saved outside of the db as a link). I have various event procedures that happen when a form is opened or a record selected depending if a jpeg has been associated with a record or not.
If the record does have a jpeg then certain fields are displayed and others hidden.
If the record does *not* have an associated jpeg then certain other fields are displayed and others hidden.
I have a cmd button that calls a set of functions (developed by Candace Tripp) that allows a user to select a new image to add to the record.
It is at this point that I would like to call the form refresh or requery function, so that the newly added jpeg would trip the hide/display criteria that changes the fields displayed.
I have tried various methods and event commands and none seem to work.
I have written a module but when I add a new image and the fuction is called, Access gives me an "Object does not support this property or method" error. I have included my function code below. At the moment the function is called at the end of the command button's "on click" event.
Any suggestions would be great as I am totally stumped.
My grateful thanks in advance
Kenny
--------------------------Code begins-------------------
Option Compare Database
Function RequeryFrm()
If Trim(Nz(txtPicture, "")) = "" Then
[Forms]![frmPlant_Main].[Form]![Garden_Sub].Image1.Visible = False
[Forms]![frmPlant_Main].[Form]![Garden_Sub].txtPicture.Visible = True
[Forms]![frmPlant_Main].[Form]![Garden_Sub].cmdBrowse.Visible = True
Else
[Forms]![frmPlant_Main].[Form]![Garden_Sub].Image1.Visible = True
[Forms]![frmPlant_Main].[Form]![Garden_Sub].txtPicture.Visible = False
[Forms]![frmPlant_Main].[Form]![Garden_Sub].cmdBrowse.Visible = False
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
RequeryFrm_Exit:
Exit Function
RequeryFrm_Err:
MsgBox Error$
Resume RequeryFrm_Exit
End Function