By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,480 Members | 771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,480 IT Pros & Developers. It's quick & easy.

Clear controls on Main form with subform

imrosie
100+
P: 222
Hello all,

I'm a YAN (yet another newbie) in need of help. I've got an image database all setup and working fine now, thanks to the help you've given me. In the main form a user can search for an image, insert a new image(combo box) with author and date and erase an image. However, when the form is closed and reopened, the information from the last user remains in the controls as well as the image (shown in the subform).

I've tried Me.undo on the close event of the form and it doesn't work. I did put it in the search combo box and it worked, but doesn't seem to work in the text boxes. ???

I'd like to use the onclose event to empty all controls, so when the next user opens this form all the controls are blank. There is no 'on exit' listed in the events list ....I told you I was a YAN.....stop laughing...

Am I on the right path? Should I figure out a function here or macro. Any suggestions would certainly be appreciated. thanks again, in advance.
May 17 '07 #1
Share this Question
Share on Google+
4 Replies


Rabbit
Expert Mod 10K+
P: 12,359
In the On Load event, just have the form move to a new record.
May 17 '07 #2

imrosie
100+
P: 222
In the On Load event, just have the form move to a new record.
in my 'ON Load' I have the following event:
Private Sub Form_Load()
OrigHght = Forms!frmimageInventory!frmimagesubform![imgPicture].Height
OrigWdth = Forms!frmimageInventory!frmimagesubform![imgPicture].Width
End Sub

This is set as follows: to cycle thru (prev & next) all images. Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click
DoCmd.GoToRecord , , acNext

Forms!frmimageInventory!frmimagesubform![imgPicture].Height = OrigHght
Forms!frmimageInventory!frmimagesubform![imgPicture].Width = OrigWdth

Exit_cmdNext_Click:
Exit Sub

Err_cmdNext_Click:
MsgBox Err.Description
Resume Exit_cmdNext_Click
End Sub

So I put your suggestion in there now I lose that ability to do 'prev & next". What I actually need is a way to prevent someone from overwriting the description (already stored with an image). When the 'onload' occurs, its typically displays the last image that was viewed, including it's description in another text box. So if a user should acidentally type a new description in the
box and click on add, it overwrites the existing description. Maybe I should put a msgbox which asks "are you sure this is the description you want storec with
"name of current image"...

Do you have any suggestions for that? thanks

I don't know how to put a msg in there whie
May 18 '07 #3

imrosie
100+
P: 222
Thanks but I figured a solution to prevent users from overwriting description for the first record that is loaded.

In the 'Add image' event I put:

Private Sub cmdNewImage_Click()
If Not IsNull([imageFile]) Then
If MsgBox("Are you sure this is the description for this image?", vbYesNo + vbQuestion) = vbYes Then
DoCmd.GoToRecord , , acNewRec
Me.cmdNext.Enabled = False
Exit_cmdNewRecord_Click:
Exit Sub

On Error GoTo Err_cmdNewRecord_Click
Err_cmdNewRecord_Click:
MsgBox Err.Description
Resume Exit_cmdNewRecord_Click
End If
End If
End Sub

thanks for your support!
May 18 '07 #4

Rabbit
Expert Mod 10K+
P: 12,359
Glad you found your solution.
May 18 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.