vba - Selecting record from a table/form in one ListBox and displaying it in a ListBox in another table/form -
i'm having trouble writing code button add selected record 1 listbox(listboxform2), listbox(listboxform1). i've got working button remove selected record listboxform1, i'll include below. if able appreciated :-)
form1 has listbox reads records table1 (to table2 inner joined) , displays them if id in table1 exists in table2. can selected , deleted using button:
private sub removemember_callouts_click() dim lngid long dim strsql string if isnull(listboxform1) exit sub end if 'get selected record's id lngid = listboxform1.value strsql = "delete * [table2] table2id = " & lngid currentdb.execute strsql 'refresh list listboxform1.requery end sub
however i'm struggling when comes programmatically adding selected record in table2(form2) table1. similar code remove click event? have ideas?
thanks
before executing delete statement. write statement insert record table 1 table 2.
"insert table1(col1, col2) select col1, col2 table2 table2id=" & lngid
i hope help
Comments
Post a Comment