|
-
Jun 3rd, 2005, 01:39 PM
#1
Thread Starter
Addicted Member
Change event with form load
I was wondering how I could get a form to load and populate the textboxes without triggering the "Change" event on the textbox.
Once the form is loaded, then I wanted to use the "Change" event.
BeengieHappy.Vaue = (SharksScore > OpponentsScore)
Go Sharks!
-
Jun 3rd, 2005, 01:50 PM
#2
Re: Change event with form load
if you cant hardcode the textbox value you could have a private boolean to say if the form is loaded or not.
VB Code:
Option Explicit
Private loaded As Boolean
'------------------------
Private Sub Form_Load()
Text1.Text = "some text"
loaded = True
End Sub
'------------------------
Private Sub Text1_Change()
If loaded = True Then
'your code
End If
End Sub
casey.
-
Jun 3rd, 2005, 01:53 PM
#3
Addicted Member
Re: Change event with form load
You could create a boolean and turn the boolean to true once the textboxes are populated. Then on each textbox change event put everything inside: 'If boolean = True then', so that they are only triggered when the boolean is true, obviously. So is that what you are looking for?
-
Jun 3rd, 2005, 01:55 PM
#4
Addicted Member
Re: Change event with form load
Hi,
You can try this.
VB Code:
Option Explicit
Dim Loading As Boolean
Private Sub Form_Load()
Loading = True
Text1.Text = "loading"
Loading = False
End Sub
Private Sub Text1_Change()
If Loading Then Exit Sub Else MsgBox "Change event fired"
End Sub
Have a good one!
BK
-
Jun 3rd, 2005, 02:11 PM
#5
Addicted Member
Re: Change event with form load
I wonder who removed my last post...sorry if it offended anyone, was just joking =P.
-
Jun 3rd, 2005, 02:12 PM
#6
Thread Starter
Addicted Member
Re: Change event with form load
It didn't work when I tried it vbasicgirl's way. I haven't tried the others yet.
VB Code:
' ****************
' This is in frmMaterials
' ****************
Private Sub flxgrdMaterials_DblClick()
frmMatDialog.PopMatEdit (flxgrdMaterials.TextMatrix(flxgrdMaterials.RowSel, 0))
frmMatDialog.Show vbModal
End Sub
' ****************
' this is in frmMatDialog
' ****************
Private Sub Form_Load()
cmdSave.Enabled = False
cmdSave.Visible = False
cmdCancel.Caption = "Close"
frmMain.Visible = False ' for some reason my other mdi form shows up :ehh:
End Sub
Public sub PopMatEdit (ByVal myMatToEdit As Integer)
' I retireve data from a database and use "rs" as the recordset (not needed for this question)
If IsNull(rs.Fields("Date").Value) = True Then
txtDate.Text = ""
Else
txtDate.Text = rs.Fields("Date").Value
End If
End Sub
Private Sub txtDate_Change()
If lblDateChck.Caption <> txtDate.Text Then
Call ButtonChange
MsgBox "txtDate_Change"
End If
End Sub
Private Sub ButtonChange()
cmdSave.Enabled = True
cmdSave.Visible = True
cmdCancel.Caption = "Cancel"
End Sub
every time the form loads, it triggers the msgbox and "ButtonChange" has obviously triggered.
BeengieHappy.Vaue = (SharksScore > OpponentsScore)
Go Sharks!
-
Jun 3rd, 2005, 02:14 PM
#7
Re: Change event with form load
I don't see where you are incorporating vbasicgirl's suggestion of using a Boolean, so how is her suggestion not working?
-
Jun 3rd, 2005, 02:16 PM
#8
Addicted Member
Re: Change event with form load
beengie, i dont see a boolean anywhere in your code. The reason you MDI form shows up is because frmMain is an mdi child.
-
Jun 4th, 2005, 04:51 AM
#9
Thread Starter
Addicted Member
Re: Change event with form load
I tried the code and then removed it. that is why I included the code.
BeengieHappy.Vaue = (SharksScore > OpponentsScore)
Go Sharks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|