• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

Tabbed Form

Experts,

I have a button on a form that opens a form (frm1)
I am now wanting to put this frm1 in a tab on the form (Project Details)

I have a lot of code on frm1.

I cant just simply copy the code from frm1 to the code on Project Details, correct?  When I run the debugger it gives me some errors.  I basically would have to add all the frm1 code on the fields, current event, after update, etc etc from to project details.  This would take a long time.  Maybe there is some trick to doing this.

Any tips?   Thank you
0
pdvsa
Asked:
pdvsa
  • 9
  • 6
  • 4
3 Solutions
 
Rey Obrero (Capricorn1)Commented:
post a sample codes that raised error.. and state the error message
0
 
IrogSintaCommented:
If you insert this form as a subform within your tab page, you should have minimal changes needed.
0
 
pdvsaAuthor Commented:
An example of one error is if on the Project Details form aftter hitting Alt F11 then Alt D for the debugger, it highlights
Private Sub Form_Current()
and gives an error of Ambiguous Name detected

It is because there are actually 2 separate Current events now.  I thought it would sort of combine the Current event from Project Details and the Current event that was on frm1.

IrogSinta:  I can not use a subform.  I have other tabs on the form and think using tabs would be best for this design.  thanks.

Maybe there is no simple shortcut.

errorOnDebug_ProjectDetailsform
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
IrogSintaCommented:
I take back what I said.  Let me rephrase... if your references to your form or controls are relative and not absolute, you will have less problems when you try to insert it in another form (whether as a subform or not).  For instance, if you refer to a control as Me.txtName, you would be fine.  But if you refer to it as Forms!MyForm!txtName, you would have problems. As Cap1 mentioned, try posting your errors and we can help you out better.
0
 
pdvsaAuthor Commented:
oh I see what you mean with a subform.  Yes, that is correct.  I was fiddling around with it and noticed that I did not have to make any changes when I inserted as a subform.  The appearance looked a little different though because I had a tab on that subform already.  Hard to explain.
0
 
Rey Obrero (Capricorn1)Commented:
<It is because there are actually 2 separate Current events now>
delete the Current event for form (frm1).
in the form "Project Details " module


you should copy the codes of form (frm1) inside the the (frm1) modules.
0
 
IrogSintaCommented:
Access will not automatically combine any procedures with the same name.  That would make troubleshooting more difficult.  You need to decide what needs to happen and stick them all into one OnCurrent event.
0
 
pdvsaAuthor Commented:
Capricorn:  
Sorry but I dont follow.  I only have code behind the form and combining the codes of both the forms.  I only know of Modules as being a sort of Global Code.  

Seems like Access cant combine procedures with the same name (IrogSinta).

I am not sure if you are attempting a workaround of Access limitation of not being able to combine procedures with the same name.  

Thanks...
0
 
Rey Obrero (Capricorn1)Commented:
a form have its own current event.

the codes you see, when you click on the form in the VBA window is the FORM's module.
0
 
pdvsaAuthor Commented:
Yes OK I see.  That is what I thought.  I dont think I can simply paste the codes in the forms module though without having to first check and see what events would be duplicates.  

Maybe I dont follow completely.
0
 
pdvsaAuthor Commented:
hitting Alt F11 takes me direclty to that forms module I believe.
0
 
Rey Obrero (Capricorn1)Commented:
<hitting Alt F11 takes me direclty to that forms module I believe. >

only if the form is open in design view and the one in focus
0
 
pdvsaAuthor Commented:
OK.  I dont think it will combine as IrogSinta mentioned.  

I am using the subform method on the tab.  I dont get any errors as I did when copying and pasting all fields into the tab on form Project Details.

All of my NotInList  (and some on click events for the buttons) events dont appear initially but I do see it there when I hit the ... (3 dots).  I guess I would have to do this manually for each field's NotInList event?
0
 
pdvsaAuthor Commented:
I am just wondering if there might be some kind of AddIn that will keep the forms events in tact adn would not have to manually click the 3 dots and add that way.  I think you know what I mean....
0
 
Rey Obrero (Capricorn1)Commented:
i am just puzzled, why your codes will be disrupted..

how did add the form (frm1) to the Projects form?



if you drag and drop (frm1) to the a tab control in projects form, the codes will be automatically be in place.
0
 
pdvsaAuthor Commented:
I did not initially do this.  I copied and pasted the fields then copied pasted the code threby having duplicate events.  

Not all codes seem to comeover when using the drag drop method you mentioned.  For example the NotInList event & maybe others. Note that the code is there but when i look at the events in the fields property, they dont appear.  I would have to click the 3 dots (...) dont know name of it.. Then that code NotInList would be there.   It is a sort of refresh.  

Is there a shortcut to "refresh" all of the NotInList codes i mentioned That did not stay intact (and others too).  Thanks.
0
 
Rey Obrero (Capricorn1)Commented:
them. there is something wrong with your forms.

it should just be as simple as, selecting the correct page in the tab control then drag and drop the form (frm1)
0
 
pdvsaAuthor Commented:
Ok.  If anyone objects to a split let me know ... Thank you
0
 
IrogSintaCommented:
I believed it would be fine if you copy and paste the controls first before pasting the code. I think you did it in reverse.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 9
  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now