我正在做人事管理系统的工资模块,请问我想在保存的时候检测输入的号工号是否与数据库中的号工员重复,如果重复则弹出提示框,能给出代码吗
数据库名:manager_dater.mdb 表名:工资 字段:员工号

解决方案 »

  1.   

    ...
    sqlString="select top 1 from 工资 where id=trim(txtID.text)"
    rst.open sqlstring,cn,.....
    if rst.eof=false then
      msgbox "员工号重复!",vbokonly,app.title
      txtid.selstart=0
      txtid.sellength=len(txtid.text)
      txtid.setfocus
    end if
    不知我这样讲合不合你的要求~感觉你都开始做人事管理(大软件吧?),好像问题不能像我理解的吧????
      

  2.   


    sqlString="select Count(*) from 工资 where id='" & trim(txtID.text) & "'"
    '如果id是数字型
    'sqlString="select Count(*) from 工资 where id=" & val(txtID.text)
    rst.open sqlstring,cn,.....
    if rst(0)>=1 then
      msgbox "员工号重复!",vbokonly,app.title
      txtid.selstart=0
      txtid.sellength=len(txtid.text)
      txtid.setfocus
    end if