Re: Passing values to a Form
You cannot pass values to the Form_Load event. Two options
1) Create two new Properties for the Form and set them before calling the Show Method.
2) Create your own Initialize function in frmAddToTable, passing the two arguments.
VB Code:
'in frmAddToTable
Public Function Initialize(Byval StateName as string ,Byval StateAbbrev as String)
'code to initialize form
Me.Show vbModal
'clean up code
End Function
'other Forms
frmAddToTable.Initialize cText, cAns
Re: Passing values to a Form
I dont know why you would need two forms for this. Put a command button on the form with its Enabled property set to False. Put two textboxes on the form, one called txtNewState and one called txtNewStateAbbrv.
In the change event for the new state textbox put
VB Code:
Private Sub txtNewState_Change()
If Len(txtNewState) > 0 Then
cmdUpdate.Enabled = True
Else
cmdUpdate.Enabled = False
End If
End Sub
In the command button, put something like
VB Code:
Private Sub cmdUpdate_Click()
Dim sSQL As String
sSQL = "INSERT INTO tablename (state, state_abbrv) VALUES ('" & txtNewState.Text & "', '" & txtNewStateAbbrv.Text & "')"
'execute in the insert query
cmdUpdate.Enabled = False
txtNewState.Text = vbNullString
txtNewStateAbbrv.Text = vbNullString
End Sub
And there you have it.
Re: Passing values to a Form
declear 2 public variable on a module and you can read it from any where
Re: Passing values to a Form
declear the variables on a module and u will b able to use them from everywhere :) have fun ;)