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

Is there a way to let a form know how it was called?

Status
Not open for further replies.

fenris

Programmer
May 20, 1999
824
CA
I have a database with a number of different tables. Each table has an associated entry form. I want to be able to edit the records of a particular table with out creating a new "edit" form. For example, I have a table called Hours. I Have a form called addHours. I want to be able to edit the table as well but I don't want to create a new form as it will be virtually identical to the addHours form. I can easily make the addHours form into the editHours form by simply if statements. Unfortunately I don't know how to tell the form how it was called, in an adding capacity or an editing capacity.

For instances some of the conditional statements would be like:

if editing then
cmdAdd.caption = "Update"
addHours.caption = "Edit Hours"

end if

So on and so fourth. the processing of the info would be handled much the same way. I could setup a global boolean to indicate this, but I would rather a more elegant solution.

Any help would be appreciated...

Troy Williams B.Eng.
fenris@hotmail.com

 
Couldn't you just put in the addHours form a variable 'Public Callingform as string' and before you load the addHours form (from the Hours form) just set this variable like
addHours.Callingform = me.name
David Paulson


 
Hi

Set up a public enum (If you use it on more than one form I suggest putting in a module.)
Now set up new form properties

example

In a module...

Public Enum DataModeEnum
dm_Edit& = 0
dm_Add& = 1
End Enum

Now in your form (frmHours)

Option Explicit
Private me_DataMode As DataModeEnum

Public Property Let DataMode(eDataMode As DataModeEnum)
me_DataMode = eDataMode
End Property

Public Property Get DataMode() As DataModeEnum
DataMode = me_DataMode
End Enum

Now you can do something like this
......
frmHours.DataMode = <Nice Intellisense over here>
......

......
If frmHours.DataMode = <Nice Intellisense over here> Then
End if

Now Inside frmHours you don't have to say
Me.DataMode - or - DataMode
but simply say

me_DataMode since that is the variable holding the value.

Have fun
caf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top