ms access - VBA: Updating a Record Set Based on current data -
ms access - VBA: Updating a Record Set Based on current data -
so i'm kind of new vba access , ran huge issue code. allow me explain, have form loads info current record , allows user edit it. i'm creating save button info has been changed updated in database. have check create sure info in textbox equal info in record set. problem if info null in database run if equal info in textbox though textbox has "updated group" in it. me bit of oversight , kinda of disappointing. question know workaround issue?
thanks in advance info.
here's answer: if rstrecset("groupname").value & "" <> txtgroupnameedit.value & "" -wayne
here's code:
dim searchgroup string dim db dao.database dim rstrecset dao.recordset dim rst dao.recordset set db = currentdb searchgroup = txtgroupnredit set rstrecset = db.openrecordset("select * tblgroupheader groupnum '*" & searchgroup & "*';", dbopendynaset) set rst = db.openrecordset("select * tblaudittable;", dbopendynaset) if rstrecset("groupname").value <> txtgroupnameedit.value or rstrecset("planstartdate").value <> txtstartdateedit.value _ or rstrecset("candate").value <> txtcandateedit.value or rstrecset("clerkid").value <> txtclerkidedit.value _ or rstrecset("populationtype").value <> txtgrouptypeedit.value or rstrecset("coc").value <> chkcocedit.value _ or rstrecset("cdhfinancialpartner").value <> cmbcdhedit.value or rstrecset("cdhprodoptions").value <> chkcdhedit.value _ or rstrecset("memberlevelbenefits").value <> chkmembbeneedit.value or rstrecset("comments").value <> txtcommentsedit.value _ or rstrecset("alsoknownas").value <> txtknownedit.value or rstrecset("bcbs").value <> chkbcbsedit.value _ or rstrecset("other").value <> chkotheredit.value rstrecset.edit rst.addnew if rstrecset("alsoknownas").value <> txtknownedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("alsoknownas").value = txtknownedit.value rst("alsoknownas").value = rstrecset("alsoknownas") rst("datechanged").value = date end if if rstrecset("planstartdate").value <> txtstartdateedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("planstartdate").value = txtstartdateedit.value rst("planstartdate").value = rstrecset("planstartdate") rst("datechanged").value = date end if if rstrecset("candate").value <> txtcandateedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("candate").value = txtcandateedit.value rst("candate").value = rstrecset("candate") rst("datechanged").value = date end if if rstrecset("populationtype").value <> txtgrouptypeedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("populationtype").value = txtgrouptypeedit.value rst("populationtype").value = rstrecset("populationtype") rst("datechanged").value = date end if if rstrecset("cdhfinancialpartner").value <> cmbcdhedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("cdhfinancialpartner").value = cmbcdhedit.value rst("cdhfinancialpartner").value = rstrecset("cdhfinancialpartner") rst("datechanged").value = date end if if rstrecset("memberlevelbenefits").value <> chkmembbeneedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("memberlevelbenefits").value = chkmembbeneedit.value rst("memberlevelbenefits").value = rstrecset("memberlevelbenefits") rst("datechanged").value = date end if if rstrecset("other").value <> chkotheredit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("other").value = chkotheredit.value rst("other").value = rstrecset("other") rst("datechanged").value = date end if if rstrecset("clerkid").value <> txtclerkidedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("clerkid").value = txtclerkidedit.value rst("clerkid").value = rstrecset("clerkid") rst("datechanged").value = date end if if rstrecset("coc").value <> chkcocedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("coc").value = chkcocedit.value rst("coc").value = rstrecset("coc") rst("datechanged").value = date end if if rstrecset("cdhprodoptions").value <> chkcdhedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("cdhprodoptions").value = chkcdhedit.value rst("cdhprodoptions").value = rstrecset("cdhprodoptions") rst("datechanged").value = date end if if rstrecset("comments").value <> txtcommentsedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("comments").value = txtcommentsedit.value rst("specialconsideration").value = rstrecset("comments") rst("datechanged").value = date end if if rstrecset("bcbs").value <> chkbcbsedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("bcbs").value = chkbcbsedit.value rst("bcbs").value = rstrecset("bcbs") rst("datechanged").value = date end if if rstrecset("groupname").value <> txtgroupnameedit.value rst("groupname").value = txtgroupnameedit.value rst("groupnum").value = txtgroupnredit.value rstrecset("groupname").value = txtgroupnameedit.value rst("groupname").value = rstrecset("groupname") rst("datechanged").value = date end if rst.update rstrecset.update end if
null values can cause weird results during comparisons. seek following:
if rstrecset("groupname").value & "" <> txtgroupnameedit.value & "" or ...
vba ms-access access-vba
Comments
Post a Comment