'要引用ADO对象库private sub cmd_save_click() rs.open "select * from XXX表",cn 'rs 为记录集对象,cn连接对象 with rs .addnew !字段名1=text1.text !字段名2=text2.text ....... !字段名n=textn.text .update end with end sub
用IF语句或者IIF判断一下: with rs .addnew if trim(text1.text)<>"" then !字段名1=text1.text if trim(text2.text)<>"" then !字段名2=text2.text ....... if trim(text3.text)<>"" then !字段名n=textn.text .update end with
rs.open "select * from XXX表",cn 'rs 为记录集对象,cn连接对象
with rs
.addnew
!字段名1=text1.text
!字段名2=text2.text
.......
!字段名n=textn.text
.update
end with
end sub
update ”字段3“,值3,这样可以吗?
用insert into 也行.
你必须要知道哪些值是肯定有输入的,其他可能无输入字段也要初始化默认值
null插入会出错误(除非你插入时能动态筛选掉空输入字段)
with rs
.addnew
if trim(text1.text)<>"" then !字段名1=text1.text
if trim(text2.text)<>"" then !字段名2=text2.text
.......
if trim(text3.text)<>"" then !字段名n=textn.text
.update
end with