Decipher code (1 Viewer)

Thedon123

Registered User.
Local time
Today, 04:36
Joined
Sep 11, 2002
Messages
98
can anyone decipher this code for meOption Compare Database

Private Sub SearchAssembly_AfterUpdate()
Me![Component].Requery
End Sub

Private Sub Section_AfterUpdate()
Me![SearchAssembly].Requery
End Sub
Private Sub Component_AfterUpdate()
Me![SearchComp].Requery
End Sub

Private Sub SelectSRO_Click()
Dim SRO As String
Dim currentRec As Long

[Form_Modify Claim].FLT_CODE_FLT_CODE_ID = Me!SearchComp.Value
[Form_Modify Claim].refresh_descriptions

currentRec = [Form_Modify Claim].CurrentRecord

DoCmd.Close acForm, "FC_Search"

'[Form_Modify Claim].Requery


DoCmd.GoToRecord , , acGoTo, currentRec
End Sub
Private Sub Close_Click()
On Error GoTo Err_Close_Click


DoCmd.Close

Exit_Close_Click:
Exit Sub

Err_Close_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Close_Click

End Sub



The code is the backend of 3 combo boxes.


I want to add a fourth one and i am stuck at this code.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:36
Joined
Feb 28, 2001
Messages
27,354
SearchAssembly_AfterUpdate() is an event routine that updates the displayed version of an embedded form/report after the SearchAssembly item is updated. Ditto for Section_AfterUpdate() and Component_AfterUpdate(). In each case, the part that appears between "Me!" and ".Requery" is the name of the item being updated.

SelectSRO_Click() is what happens after you click the SelectSRO control or button. It appears to load a value to a control called FLT_CODE_FLT_CODE_ID which is in a form called Form_Modify Claim, after which it executes a routine local to that form. You would need to examine the form's class module to see exactly what "refresh_descriptions" does, though I'll bet it merely updates displayed values in controls on that form. (That's a guess on my part.) Once that operation is completed, this code copies a record selector from the subform. The subform is closed, then a specific record is sought for the main form based on the value extracted from the subform. I.e. a direct jump to a specific record based on data returned by whatever happens in the "refresh_descriptions" code.

The Close_Click() code is plain vanilla Command Button Wizard output for what happens when you click a button called Close. It closes the current form. This appears to be unmodified from the exact code that the wizard would build for you if you had inserted the command button with wizards enabled.
 

Fornatian

Dim Person
Local time
Today, 04:36
Joined
Sep 1, 2000
Messages
1,396
Code:
Private Sub SearchAssembly_AfterUpdate() 
Me![Component].Requery 
End Sub

Refreshes the recordsource for the control 'component' on the current form

Code:
Private Sub Section_AfterUpdate() 
Me![SearchAssembly].Requery 
End Sub

Refreshes the recordsource for the control 'searchassembly' on the current form

Code:
Private Sub Component_AfterUpdate() 
Me![SearchComp].Requery 
End Sub

Refreshes the recordsource for the control 'searchcomp' on the current form

Code:
Private Sub SelectSRO_Click() 

Dim SRO As String 'THESE AREN'T USED
Dim currentRec As Long 'THESE AREN'T USED

[Form_Modify Claim].FLT_CODE_FLT_CODE_ID = Me!SearchComp.Value

Changes the value of a control on the form modify claim

Code:
[Form_Modify Claim].refresh_descriptions

Calls a sub procedure on the form modify claim - presumably refreshing descriptions :)

Code:
currentRec = [Form_Modify Claim].CurrentRecord

Sets a variable currentRec to the currentrecord number on the open form

Code:
DoCmd.Close acForm, "FC_Search"

Closes a form

Code:
'[Form_Modify Claim].Requery

This does nothing because it is commented out, it would requery the modify claim form though.


Code:
DoCmd.GoToRecord , , acGoTo, currentRec

Sets the current record number on the open form to variable currentRec
 

Thedon123

Registered User.
Local time
Today, 04:36
Joined
Sep 11, 2002
Messages
98
Thanks Thats brilliant the code makes sense now.
 

Travis

Registered User.
Local time
Yesterday, 20:36
Joined
Dec 17, 1999
Messages
1,332
Code:
Private Sub SearchAssembly_AfterUpdate() 
   'Event runs after the SearchAssembly Control is Updated
   'Requeries the Control named Component (Possibly a Combo or List Box
   Me![Component].Requery 
End Sub 

Private Sub Section_AfterUpdate() 
   'Requeries the Control named SearchAssembly (Possibly a Combo or List Box
  Me![SearchAssembly].Requery 
End Sub 

Private Sub Component_AfterUpdate() 
   'Requeries the Control named SearchComp (Possibly a Combo or List Box
  Me![SearchComp].Requery 
End Sub 

Private Sub SelectSRO_Click() 
Dim SRO As String 
Dim currentRec As Long 

'Sets a Field called FLT_CODE_FLT_CODE_ID on the form named Form_Modify Claim equal to the current forms SearchComp Field
[Form_Modify Claim].FLT_CODE_FLT_CODE_ID = Me!SearchComp.Value 

'Runs a Sub Procedure on Form_Modify Claim called refresh_descriptions
[Form_Modify Claim].refresh_descriptions 

'You can use the CurrentRecord property to identify the current record in the recordset being viewed on a form.
'In this case the Current Record of Form_Modify Claim.
currentRec = [Form_Modify Claim].CurrentRecord 

'Closes the form called FC_Search
DoCmd.Close acForm, "FC_Search" 

'[Form_Modify Claim].Requery 

'Moves to the Record on the current form that is = to the currentRec
DoCmd.GoToRecord , , acGoTo, currentRec 
End Sub 

Private Sub Close_Click() 
On Error GoTo Err_Close_Click 

'Closes the current form
DoCmd.Close 

Exit_Close_Click: 
Exit Sub 

Err_Close_Click: 
MsgBox Err.DESCRIPTION 
Resume Exit_Close_Click 

End Sub
 

Thedon123

Registered User.
Local time
Today, 04:36
Joined
Sep 11, 2002
Messages
98
Probably a silly question but what does control mean in the code below.

'Event runs after the SearchAssembly Control is Updated
'Requeries the Control named Component (Possibly a Combo or List Box
Me![Component].Requery

What i am basically trying to ask is where oes the control come from
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:36
Joined
Feb 28, 2001
Messages
27,354
A control is a visual object in a form or report. For instance, a text box, combo box, list box, check box, toggle button, option group, ... PLUS some less obvious things like labels, lines, rectangles, ...

A control is BOUND if it is automatically associated with a field in some underlying record and UNBOUND if there is no such automatic association.
 

Users who are viewing this thread

Top Bottom