Minggu, 14 April 2013

[MS_AccessPros] Re: SET statement

 

Hi Phucon,

Are you wanting to cycle through all of the items in
the ListBox for the same recordset?

If so, then you can have a loop in your routine to
cycle through all of the Listbox entries using just
one Set statment in each routine.

If that is not what you want then you need to give
more information about what the task consits of.

Regards, Clive.

--- In MS_Access_Professionals@yahoogroups.com, "saigonf7q5" <saigonf7q5@...> wrote:
>
>
> Hello
>
>
> My form module hasseveral procedures. The procedues all have the same
> "SET" statements,like the set frm and set rs that's shown in the cmdSave
> and cmdDelete below:
>
> Is it possible to recreatesomething like a variable that the all
> procedures can refer to it, so the SET Statement does not need to be
> repeated in each sub?
>
> I have tried to place them out side the procedure, but ended up with
> error.
>
>
> Phucon
>
>Private SubcmdSave_Click()
> On Error GoToErrorHandler
> Set frm = Form_frmAllStaff
> Set rs = CurrentDb.OpenRecordset("tblAllStaff",dbOpenDynaset)
> With rs
> .FindFirst "[Sid] = " &frm!lstBox.Column(0)
> If Not rs.NoMatch Then
> .Edit
> !An = Me.txtDAn
> !Re = Me.txtDRe
> !Ex = Me.txtDEx
> !Rn = Me.txtDRn
> .Update
> .Requery
> End If
> End With
>ExitProcedure:
> rs.Close
>Exit Sub
>ErrorHandler:
> MsgBox "Err = " & Err &vbCrLf & Err.Description
> Resume ExitProcedure
> Resume
>End Sub
>
>Private SubcmdDelelte_Click()
>On Error GoToErrorHandler
> Set frm = Form_frmAllStaff
> Set rs = CurrentDb.OpenRecordset("tblAllStaff",dbOpenDynaset)
> With rs
> .FindFirst "[Sid] = " &frm!lstBox.Column(0)
> If Not rs.NoMatch Then
> .Delete
> .
> .
> .
> End If
> End With
>ExitProcedure:
> rs.Close
> Exit Sub
>ErrorHandler:
> MsgBox "Err = " & Err &vbCrLf & Err.Description
> Resume ExitProcedure
> Resume
>End Sub

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar