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

Displaying a form again

Status
Not open for further replies.

EscapeUK

Programmer
Jul 7, 2000
438
GB
I have 2 forms, lets say the are called introform and dataform. I have split my problem into 2 parts

1) On my intro form I have 2 buttons New and Edit. When New is pressed the data form is opened and the fields are blank. When Edit is pressed the dataform is opened and populated with values from intoform.

2) When the dataform has been completed i need to know if the new or edit button was pressed on the introform. How do I do that. The reason is that a different stored procedure is called depending if the the data is new or edited
 
This might not be what you were asking, but on your introform page you could dimension a string variable such as buttonPressed, when either NEW or EDIT buttons are pressed, you could assign a value "NEW" or "EDIT" to the variable during the specific Button_onClick() event.

Then, while you are on your dataform page, you can check the contents of the introform.buttonPressed variable and determine which button had been pressed.
 
Where and how should I declare this variable
 
Try this, on the edit form declare a private variable:

private editPushed as boolean

public property let setIsEdit(t as boolean)
editpushed = t
end property

'The code above will allow the form to know which routine to call, the edit or the new

On the intro form call the editform like so:

dim frm as new editform
frm.setIsEdit true 'This will be false if it is new data
frm.show
set frm = nothing

The above code should go into the new and edit buttons of the introform and the line frm.setIsEdit should be set to true if the code is in the edit button's click event and false if it is in the new button's click event.

Hope this helps....
Troy Williams B.Eng.
fenris@hotmail.com

 
Or... you could do this without declaring or setting a variable....
On your "Introform":[tt]
Private Sub Command1_Click()
Dataform.Tag = "New"
Dataform.Show
End Sub
Private Sub Command2_Click()
Dataform.Tag = "Edit"
Dataform.Show
End Sub[/tt]

On your "Dataform":[tt]
Private Sub Form_Activate()
Select Case Me.Tag
Case "New"
MsgBox "Command1 was clicked"
Case "Edit"
MsgBox "Command2 was clicked"
Case Else
MsgBox "Other event occured"
End Select
End Sub
[/tt]

BTW: The form Activate event may not be the best place to do this.
VCA.gif

Alt255@Vorpalcom.Intranets.com​
 
On the function to the show of the dataform just pass another param a intMode as boolean or int if you ever invision something else on that app. So you can later have a select case for which stored proc to call.
Function initDataForm(params..., Optional intMode as integer)
'Your code to edit or input the form values
' Now figure out what the heck you want to do with them.
Select case intMode
Case 0 'New
strSQL = "sp_NewData"
Case 1 'Edit
strSQL = "sp_EditData"
Case else 'App done messed up
strSQL = "Error"
End Select
Chad
tinman@thelandofoz.org

Tinman,

Welcome to OZ.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top