MS Access combo box setting a record with two primary keys -
i have database 2 primary keys, 1 line number , 1 phase of construction. reason have projects may use same line number must track several phases of project entirely seperatly. have combo box drive record information on form. works fine, when have more 1 phase bring line's first phase , not other 4 phases. when other phas 1 picked results first phase information.
is there way tie combo box 2 fields select proper record based on both fields picked?
or maybe need rething way form brought up... there better way this?
code used select record:
sub setfilter() dim lsql string lsql = "select * tbllinedata_horizon" lsql = lsql & " lineno = '" & cboselected & "'" form_frmhorizon_sub.recordsource = lsql end sub private sub cboselected_afterupdate() 'call subroutine set filter based on selected line number setfilter end sub private sub form_open(cancel integer) 'call subroutine set filter based on selected line number setfilter end sub
a basic idea, you'll want tweak behaviour bit , have more checks. when form loads, have ability select lineno
. when cbxlineno
has value in it, enables cbxphaseno
selection , upon selection, changes recordsource
of subform.
private sub cbxlineno_afterupdate() if isnull(cbxlineno) cbxphaseno.enabled = false else cbxphaseno.enabled = true cbxphaseno.rowsource = "select phaseno tbllinedata_horizon lineno = " & cbxlineno & ";" end if end sub private sub cbxphaseno_afterupdate() if isnull(cbxphaseno) = false , isnull(cbxlineno) = false tbllinedata_horizon_sub.form.recordsource = "select * tbllinedata_horizon lineno = " & cbxlineno & " , phaseno = " & cbxphaseno & ";" end if end sub private sub form_load() cbxlineno.enabled = true cbxphaseno.enabled = false cbxlineno.rowsource = "select lineno tbllinedata_horizon group lineno;" end sub
Comments
Post a Comment