Open form with two number criteria

  • Thread starter Thread starter disneygoof via AccessMonster.com
  • Start date Start date
D

disneygoof via AccessMonster.com

I must be going blind looking at this...I can not figure out why this code
does not work.....

DoCmd.OpenForm "frmProjectManagerTBCCostSheet", , , "[ProjectID] =" & Forms!_
frmBlogProjects.ProjectID & " And [BlogNo] = " & Forms!frmBlogProjects.BlogNo

Can someone point out my error?

I keep getting "Run-time error: 2465 - Application-defined or object-defined
error"
 
The continuation character falls within a reference to a form and is not
preceded by a space. I doubt this would even compile. Try:

DoCmd.OpenForm "frmProjectManagerTBCCostSheet", , , "[ProjectID] =" & _
Forms!frmBlogProjects.ProjectID & " And [BlogNo] = " &
Forms!frmBlogProjects.BlogNo

Or perhaps more readably:

Dim strCriteria As String

strCriteria = "[ProjectID] = " & _
Forms("frmBlogProjects").ProjectID & _
" And [BlogNo] = " &_
Forms("frmBlogProjects").BlogNo

DoCmd.OpenForm _
FormName:="frmProjectManagerTBCCostSheet", _
WhereCondition:=strCriteria

Ken Sheridan
Stafford, England
 
Thanks for the insight...however I guess I should have shown the code a
little better. Actually in my program it's one long code line, I only used
the continuation character in this email thread...my mistake for not making
that clear. Late last night I rewrote the code so instead of search two
criteria, I search for an ID number and this seems to work now. Thank you
for your help.
David

Ken said:
The continuation character falls within a reference to a form and is not
preceded by a space. I doubt this would even compile. Try:

DoCmd.OpenForm "frmProjectManagerTBCCostSheet", , , "[ProjectID] =" & _
Forms!frmBlogProjects.ProjectID & " And [BlogNo] = " &
Forms!frmBlogProjects.BlogNo

Or perhaps more readably:

Dim strCriteria As String

strCriteria = "[ProjectID] = " & _
Forms("frmBlogProjects").ProjectID & _
" And [BlogNo] = " &_
Forms("frmBlogProjects").BlogNo

DoCmd.OpenForm _
FormName:="frmProjectManagerTBCCostSheet", _
WhereCondition:=strCriteria

Ken Sheridan
Stafford, England
I must be going blind looking at this...I can not figure out why this code
does not work.....
[quoted text clipped - 6 lines]
I keep getting "Run-time error: 2465 - Application-defined or object-defined
error"
 
Back
Top