473,324 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Clear controls on Main form with subform

imrosie
222 100+
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
4 1906
Rabbit
12,516 Expert Mod 8TB
In the On Load event, just have the form move to a new record.
May 17 '07 #2
imrosie
222 100+
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
222 100+
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
12,516 Expert Mod 8TB
Glad you found your solution.
May 18 '07 #5

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

Similar topics

4
by: Deano | last post by:
If I create 2 or more records in my subform and I then delete the main record, then all the controls on my subform disappear. Yet if there is only one record in the subform then it gets deleted...
5
by: Lyn | last post by:
Hi, I have a form which contains a number of subforms in different pages of a tab control. In the detail section of each subform, I list records related to the main form record, but from...
0
by: DFS | last post by:
This works fine for me, and is very useful. You can't nest tab controls on each other, so: * start with main form * tab control 1 is placed on main form * subform 1 is placed on tab control 1...
1
by: Momo4 | last post by:
I have a unbound main form with unbound fields that correspond to fields on a bound data sheet subform. As you enter data on the subform, the corresponding fields get updated through code (e.g....
7
by: lauren quantrell | last post by:
A while back I got a requirement for the client to be able to adjust the relative heights of two subforms by click-dragging the mouse and I came up with a kludge solution using a border control...
0
by: Lauren Quantrell | last post by:
In terms of resources, wondering if it makes a difference in adopting one of the three options below for resizing controls on a form and controls on a subform at the same time. option a.) Put...
3
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality...
6
imrosie
by: imrosie | last post by:
Hello, Does anyone have a simple cmd to clear all controls on Subform without using the SetFocus? Two of the controls are expressions, so they can't be set to Null. Then after clear return control...
5
aas4mis
by: aas4mis | last post by:
I haven't had much luck with specific controls, their properties and loops in the past. I thought I would share this tidbit of code, feel free to modify/modularize in any way to suit your needs. This...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.