Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 05-12-2004, 03:30 AM   #1 (permalink)
Addict
 
Location: Grey Britain
[vb6] referring back to a form

I'm working with some source code where formA loads formB, the formB accesses and modifies a recordset belonging to formA. I've been asked to modify the source in such a way that formB can be loaded from any of forms A, C, D, E or F (all of which are incidences of formAlfa) and refer to whichever form it was loaded from.

I could do it by making a completely different form like formB, for each of these calls, but that seems a bit ass.

Any ideas how I can say 'formthatcalledme.data1.recordset', rather than formA.data1.recordset, formB.data1.recordset, etc? Or is there any other way to work round this?
__________________
"No one was behaving from very Buddhist motives. Then, thought Pigsy, he was hardly a Buddha, nor was he a monkey. Presently, he was a pig spirit changed into a little girl pretending to be a little boy to be offered to a water monster. It was all very simple to a pig spirit."
John Henry is offline  
Old 05-12-2004, 07:26 PM   #2 (permalink)
Tilted
 
Two ways: Implements, or late binding. Late binding would probably be easiest. If you cast the Form variables to Object, you can make whatever calls you want to them, and they're not checked at compile time, only at run time, so you can go:

Dim frm As Form
Set frm = FormA 'For example
Dim o As Object
Set o = frm
o.Data1.whatever

And it'll work, provided that FormA really does have a Data1 property.

Implements is perhaps the more correct way of doing things, but much more involved, so I won't go into it 'less you really want.
magua is offline  
Old 05-13-2004, 12:59 AM   #3 (permalink)
Addict
 
Location: Grey Britain
Excellent, thanks. I shall use that one next time as I'm expecting to have a similar problem again.

My boss was breathing down my neck on this one, so in the end I bodged it by passing a string to formB which held the name of the form it came from, then making a giant switch.
__________________
"No one was behaving from very Buddhist motives. Then, thought Pigsy, he was hardly a Buddha, nor was he a monkey. Presently, he was a pig spirit changed into a little girl pretending to be a little boy to be offered to a water monster. It was all very simple to a pig spirit."
John Henry is offline  
 

Tags
back, form, referring, vb6


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 02:38 AM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73