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

tab control & refreshing data? 2

Status
Not open for further replies.

jgoodman00

Programmer
Jan 23, 2001
1,510
I have solved my previous problem, but when data is entered into two fields on one subform (which lives on one tab), i need it to refresh the record when the tab is changed. At the moment I have a refresh button to do this, but I want to make this refresh automatic upon switching tabs.

Any ideas anyone? James Goodman
j.goodman00@btinternet.com
 
Hallo,

If you select your tab control (in design view) and view Properties, you'll see the On Change Property. Put the code from your refresh button into the On change event procedure and Bob's your uncle.

- Frink
 
Hi James,
In your tabcontrol's "On Change" event add something like:

Me.NameOfSubFormAsSeenByTheMainForm.Requery

Should do it!
Gord
ghubbell@total.net
 
Dear James and Frink and Gord:
I wonder why I can only see the On Change property when I click a tab in FORM view rather than design view?
Gus
 
It's there Gus! In design view don't click on the page like in form view, instead just click on the outer edge or frame of the control. Just more bizarre Access things to remember!
P.S. Either way don't forget to play with the tab width property if you want to keep that nifty balanced look....! Gord
ghubbell@total.net
 
Thank you, Gord. I appreciate your help more than you suppose. In my study of macros now I have another problem...(or should I start a new thread?) I've constructed a simple macro I named RefreshIt, without argument, to requery the query the form is based on when a control is changed. (The only thing in the macro is the word "Requery" in the action column.) The control (PropertyID) is a text box, integer, four digit identifying number, mask= 0000, edit=yes, etc. When I go to "On Change", and select the macro (the only one in the list), then upon opening the form, the control does not allow me to edit it. The control is the key of one of the tables the original query is based on. (The only thing in the 'On Change' line is the word "RefreshIt".)If you read this far, thanks for any suggestions.
Muchas gracias. :)
Gus
 
Bienvenue!
Toss that form in design view and find that event that says refreshit. Scroll its choices and select "event procedure". You'll notice the little ellipse "..." button just on the right. Click it! This opens VB and labels up the sub procedure for you. Now in between the "labels" type in something like:

Me.Requery

You are done! Me is the form and requery me says go and run that query again. This should work well. Close and save and give it a try. You're benefit in doing this in VB is that you can add "error handling" to the event so if something goes wrong, you'll get a nice message or no message. You control it.

Lets change what I show above to this:

On error goto ErrGus
Me.Requery

ExitGus:
Exit Sub

ErrGus:
MsgBox Err.Number & " " & Err.Description,VBInformation,"An error has occured."
Resume ExitGus


Now if any thing goes wrong you'll get an informative message instead of a macros "Halt" thing. Sounds like you're full of good ideas so I'll warn you, macros have there little place in the whole scheme of things but the more you can do in VB, well you can do more in VB safer and in no time easier too! Have fun Gus!



Gord
ghubbell@total.net
 
Dear Gord:
I pasted the code you gave me in between the labels...but still can't edit the control it's bound to. (No error msg, either.) The other controls I've tried allow editing, so it seems to be something about this particular control. I'll probably figure out that it was something I forgot to describe, and it will be a good learning experience (don't you hate those?) Thanks for the attention to my request. I'm taking a week's vacation this afternoon--I'll be back tonight. The last person I voted for was Martin Sheen for President. But you get my vote for Helper of the Week or whatever. Is there a trophy?
Hasta luego.
Gus
 
Bon soir Gus!
Well that's pretty odd I have to say. Martin Sheen....(thank you Gus. :) No, perhaps that text field has its Locked property True? Enabled False? If you go to the query that is the basis of your form, can you edit it there? I'd check that last one first as sometimes is the case that certain fields "pulled in" in a query are not editable. MS has some big speach about this and at the end they basically say the samething...try it?! If it continues to misbehave just delete the textbox and replace it afresh. I mentioned in another post somewhere, of a time when I had an entire form go sour with no explanation. To this day I have no idea why...
à demain et merci encore!
Gord
ghubbell@total.net
 
Gord:
Finalement, c'était si facile! Finally, and it was so easy! I just followed your suggestion and reinstalled the control and there it was. Thanks again. And I get frustrated when I have to tell users again and again, "Just close all your programs, and reboot. Usually that will solve it." When all else fails, reinstall the control. OK. Thanks again, very much.
Gus :)
 
Eh bien! Maitenant ca marche! (For the other viewers: "Well good! Now it works!) Good to see and your very welcome Gus. Its been a slice.
Tierra Del Fuego, :) Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top