Form when populate execute code

F

Franck

I have a form. I have it bind to a table and with custom button i can
move trought the records. Till there it's pretty easy.
The form is use for the tech support, sumone put a call we answer, fill
up a ticket doing updates like calling another person, doing
intervention on distant servers and all
for example solving a problem took 2 days (nothign ot have wiht day
it's just an example) when it's finish we change the ticket status from
open to close
this form can be open :
- completly clean (new record mode)
- with a filter so you can modify it
when you open it i want that people can't modify anything from the form
if the combobox for the status show "Closed"
I have the code to lock everything by looping to a (for each ctrl in
me.controls), on a button click it work, now i have to make it run each
time the form finish filling up all the fields with the record, no
matter if it show nothing (ex : filter doesnt return any data)

Im a nearly expert level vb Programmer but not used to vba controling
office objects

I first thaugt to use the afterupade method of the form. it run the
code only if the record is closed after it does nothing dont even run
the code, i even check if it lock the form and it's not, if i do it on
the field status the code got run once in a while depending on his
humor. I'm lokking for a method that isn't shown in the list that is
sumthing like
form_RecordSetLoaded()

Private Sub Form_AfterUpdate()

If Me.status.Value = "02" Then 'if it's closed
Dim c As Control

On Error Resume Next

For Each c In Me.Controls
If c.Name = "ticket" Or c.Name = "Commande101" Or c.Name =
"Commande102" Or c.Name = "Commande103" Or c.Name = "Commande104" Or
c.Name = "Commande105" Or c.Name = "Commande106" Or c.Name =
"frm_ticket" Then
Else
c.Locked = True
End If
Next

Else 'if it's not closed unlock all (in case it was lock)

Dim c2 As Control
For Each c2 In Me.Controls
c.Locked = False
Next

End If
End Sub

im trying to make it the most simple as possible, just want it to work,
More info :
Using Windows XP pro latest patch
Using office 2003 Latest patch
Using linked table to another access database (split in 2 : 1 is
database the other is interface)
i looked for issue on access 2003 and the afterupdate i havent found
anything, even if it's not the good method, this one is bugged
 
G

Guest

Use the form's Current Event.

If Me.NewRecord Then
'Unlock Everything
ElseIf [Status] = "Closed" Then
'Lock Everything
Else
'Unlock Everything
End If
 
C

Cinzia

Franck said:
I have a form. I have it bind to a table and with custom button i can
move trought the records. Till there it's pretty easy.
The form is use for the tech support, sumone put a call we answer, fill
up a ticket doing updates like calling another person, doing
intervention on distant servers and all
for example solving a problem took 2 days (nothign ot have wiht day
it's just an example) when it's finish we change the ticket status from
open to close
this form can be open :
- completly clean (new record mode)
- with a filter so you can modify it
when you open it i want that people can't modify anything from the form
if the combobox for the status show "Closed"
I have the code to lock everything by looping to a (for each ctrl in
me.controls), on a button click it work, now i have to make it run each
time the form finish filling up all the fields with the record, no
matter if it show nothing (ex : filter doesnt return any data)

Im a nearly expert level vb Programmer but not used to vba controling
office objects

I first thaugt to use the afterupade method of the form. it run the
code only if the record is closed after it does nothing dont even run
the code, i even check if it lock the form and it's not, if i do it on
the field status the code got run once in a while depending on his
humor. I'm lokking for a method that isn't shown in the list that is
sumthing like
form_RecordSetLoaded()

Private Sub Form_AfterUpdate()

If Me.status.Value = "02" Then 'if it's closed
Dim c As Control

On Error Resume Next

For Each c In Me.Controls
If c.Name = "ticket" Or c.Name = "Commande101" Or c.Name =
"Commande102" Or c.Name = "Commande103" Or c.Name = "Commande104" Or
c.Name = "Commande105" Or c.Name = "Commande106" Or c.Name =
"frm_ticket" Then
Else
c.Locked = True
End If
Next

Else 'if it's not closed unlock all (in case it was lock)

Dim c2 As Control
For Each c2 In Me.Controls
c.Locked = False
Next

End If
End Sub

im trying to make it the most simple as possible, just want it to work,
More info :
Using Windows XP pro latest patch
Using office 2003 Latest patch
Using linked table to another access database (split in 2 : 1 is
database the other is interface)
i looked for issue on access 2003 and the afterupdate i havent found
anything, even if it's not the good method, this one is bugged

Hi Frank,
if I understand your problem, the right event to call your routine to lock
/ unlock the controls is: Form_Current.

Bye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top