sql - #Name? on form after requery in Access 2010 -


i using vba , sql re-query main form based on criteria entered in several controls on pop form. far can tell code running correctly, database re-queried based on criteria enter, 2 of controls on main form show #name? or blank after re-querying based on criteria. know how can fix this???

the code runs re-query is:

public sub superfilter() on error goto err_advancedfilter_click dim strsql string     dim strcallnumber string dim strasgntech string dim strclientid string dim strcallgroup string dim strpriority string dim stropenstatus string          if isnull(forms![frmtips&tricks].txtcallnumber) = false             strcallnumber = " (((callinfo.callnumber) = forms![frmtips&tricks].[txtcallnumber])) , "         else             strcallnumber = ""         end if           if isnull(forms![frmtips&tricks].cboasgntech) = false             strasgntech = " (((callinfo.asgntech) = forms![frmtips&tricks].[cboasgntech])) , "         else             strasgntech = ""         end if           if isnull(forms![frmtips&tricks].cboclientid) = false             strclientid = " (((callinfo.clientid) = forms![frmtips&tricks].[cboclientid])) , "         else             strclientid = ""         end if           if isnull(forms![frmtips&tricks].cbocallgroup) = false             strcallgroup = " (((callinfo.asgngroup) = forms![frmtips&tricks].[cbocallgroup])) , "         else             strcallgroup = ""         end if           if isnull(forms![frmtips&tricks].cbopriority) = false             strpriority = " (((callinfo.severity) = forms![frmtips&tricks].[cbopriority])) , "         else             strpriority = ""         end if           if forms![frmtips&tricks].optopenstatus.value = 1             stropenstatus = " (((callinfo.openstatus) = true))"         else             stropenstatus = " (((callinfo.openstatus) not null ))"         end if      strsql = "select callinfo.callnumber, callinfo.clientid,* " & _             "from dbo_hdtechs inner join ([user] inner join callinfo on user.clientid = callinfo.clientid) on dbo_hdtechs.techname = callinfo.asgntech " & _             "where " & strcallnumber & strasgntech & strclientid & strcallgroup & strpriority & stropenstatus & _             "order callinfo.rcvddate;"       form.recordsource = strsql     me.cbocallnumber.rowsource = strsql     form.requery  if me.recordsetclone.recordcount = 0      msgbox "no records found: try diferent criteria."     form.recordsource = "qryservicerequestentry"     me.cbocallnumber.rowsource = "qryservicerequestentry"     exit sub end if  me.cmdsuperfilteroff.visible = true    exit sub  exit_cmdadvancedfilter_click:     exit sub  err_advancedfilter_click:     msgbox err.description     resume exit_cmdadvancedfilter_click    end sub 

the first control in question combo box displays client name callinfo form (main form). control source: clientid , when expanded lists available clients select users form (user id linked between user form , callinfo form). row source: select user.clientid [user]; after re-query, combobox blank, showing #name? if click on it.

the second control in question text box shows client's phone number. control source: phoneno after re-query, text box displays #name?

the third control in question text box displays clients office location. control source: location baffles me text box displays correctly after re-query. don't know why display correct data when phone number text box not, seeing similar , work similar data....

to compare, the form record source based on: select callinfo.callnumber, callinfo.clientid, callinfo.rcvdtech, callinfo.rcvddate, callinfo.closedate, callinfo.classroom, callinfo.problem, callinfo.currentstatus, callinfo.resolution, callinfo.severity, callinfo.openstatus, callinfo.asgntech, dbo_hdtechs.email, callinfo.fullname, callinfo.asgngroup, user.location, user.phoneno, callinfo.openstatus dbo_hdtechs inner join ([user] inner join callinfo on user.clientid = callinfo.clientid) on dbo_hdtechs.techname = callinfo.asgntech (((callinfo.openstatus)=true)) order callinfo.rcvddate;

just going on wrote, may take different approach (just personal preference).

  1. i change of 'isnull' tests check 'empty'. i.e. if isnull(forms![frmtips&tricks].cboclientid) = false , ...cliientid <> ""
  2. just today had issue relating form references in query clause, changed to: strclientid = " (((callinfo.clientid) = '" & forms![frmtips&tricks].[cboclientid] & "')) and"
  3. add debug.print of generated sql, @ , try run sql manually luck, wayne

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -