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

Tab Control with Command Buttons

Status
Not open for further replies.

seb2

Technical User
Feb 6, 2002
27
0
0
US
I have a 5 tabbed form with subforms from 5 separate tables. Currently each subform has it’s own set of command buttons for ‘Add New Record’, ‘Delete Record’, ‘Save’, ‘Exit’.

What I’d like to do is to move the command buttons from the subforms to the face of the tab form as we see daily on the ’97 Database view with ‘Open’, ‘Design’, ‘New’, etc.

I’d love help with the coding of the buttons (i.e. how to identify which table is being saved at which time.)

Anyone gotta example of this or can walk me thru it???

Assistance is greatly appreciated! :)
 
You might try using the ActiveForm property in a case statement similar to below:

Dim CurForm as Form
Set CurForm = Screen.ActiveForm

Select Case Curform.Name
CASE "Form1"
Code to save table 3 data
CASE "Form2"
Code to save table 2 data
CASE "Form3"
Code to save table 3 data
CASE "Form4"
Code to save table 4 data
CASE "Form5"
Code to save table 5 data
End Select

I haven't actually tried this code, but think it will work. I hope it works for you.

dz
 
Sorry, there was a typo in my example. It should have read:

Select Case Curform.Name
CASE "Form1"
Code to save table 1 data
CASE "Form2"
Code to save table 2 data
CASE "Form3"
Code to save table 3 data
CASE "Form4"
Code to save table 4 data
CASE "Form5"
Code to save table 5 data
End Select

I don't know if the ActiveForm will point to the right form if you click on a button on the tab form. If it does, you can save a value to a variable in the Form's LostFocus property and test that value in the CASE statement. That is probably a better solution anyway.

dz
 
Seem to be having problems connecting down to the subform level with the command buttons... 'Save' works, but I wonder if it is really just Saving items because the record has lost focus or because my code is working. 'Create New Record' & 'Undo' aren't working...

On Access's Database window it seems as if the command buttons are on the tab control.... Do you think that each tab control has the buttons and they only seem to be one set OR are they actually just one set of buttons?
 
You should be able to use the same buttons on the main form if they have the same purpose. I have written programs that do something similar. How did you implement it? You might set a breakpoint in your code and run the program to see if it is getting there. Step through it and see what happens. You can also monitor variables with the debugger.

dz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top