Jumat, 23 Oktober 2015

Re: [MS_AccessPros] how to avoid repeating code?

 

Youssef-


Write the code as a public function or sub (in a standard module) and pass it the value of ModelCode so that it can open the form.

Public Sub OpenModel(strModelCode As String)

    DoCmd.OpenForm "frm_ModelCodes", WhereCondition:="ModelCode = '" & strModelCode & "'"

End Sub

In your form:

    OpenModel Me.ModelCode



John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)




On Oct 23, 2015, at 9:15 PM, youssef2309@gmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

I designed a database which will serve automotive production line in some problems
so, many of my database forms contains a field "ModelCode"
now i repeated a code to open the "frm_ModelCodes" form when i double click the field "ModelCode" on each form

My request is
is it possible to avoid repeating this code in each form.
or
i need to know how to type a code in a module and call it from all forms to open "frm_ModelCodes" form.

your quick support will be highly appreciated.

Youssef


__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar