Access 2007, VBA: Checking for duplicates, have null field -


i want check if field has duplicates emp table. works except need create exception when there's nothing in field aka null exception.

private sub cmdduplicates2_click()  dim name string dim dbs dao.database dim rst dao.recordset  set dbs = currentdb set rst = dbs.openrecordset("emp", dbopendynaset) name = me.personnel rst.findfirst "[personnel] = '" & name & "'" if rst.nomatch         msgbox "no duplicates found"   else         msgbox "name in database" end if  end sub 

edit: doing now. if it's null says "please enter name." says "no duplicates found." want "please enter name." if field blank.

private sub cmdduplicates2_click() dim name string dim dbs dao.database dim rst dao.recordset  set dbs = currentdb set rst = dbs.openrecordset("emp", dbopendynaset)  if isnull(me.personnel) msgbox "please enter name." else: name = me.personnel  rst.findfirst "[personnel] = '" & name & "'" if rst.nomatch         msgbox "no duplicates found"   else         msgbox "name in database" end if  end sub 

do this:

if isnull(me.personnel) name = "empty" else name = me.personnel 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -