How can i simulate the code in Macro?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I need to write in procedure code when the macro is truncated the criteria.

I have two fields, and I would do in the macro on the subject of to open
report in print preview format and its where criteria as follows:
[hb] Like "*" & [Forms]![searchHearB]![Ssearch] & "*" Or [hb] Like
[Forms]![searchHearB]![Ssearch] & "*" Or "*" & [de] Like
[Forms]![searchHearB]![Ssearch] & "*" Or [de] Like "*" &
[Forms]![searchHearB]![Ssearch] Or [de] Like [Forms]![searchHearB]![Ssearch]
& "*"

I have problem to concatenate them in the code procedure.

I try from the simple but not success, the problem exists even it succeeds
in doing code format that Access can't find the field, though the fields
exists in the Report1.

Thans,
 
Try using code instead of a macro.
Using code you can use the Debug and step through the lines, and view each
value.

Something like

Dim MyCriteria As String
MyCriteria = "[hb] Like *" & [Forms]![searchHearB]![Ssearch] & "* Or [de]
Like *" & [Forms]![searchHearB]![Ssearch] & "*"

Docmd.OpenReport "ReportName" , , , MyCriteria
 
Hi,

I have test the code, but it gets bugs, and I can't fix. The problem is at
the "*" when concatenated on the last of the the sentence that it should be "
to close the sentence, but I don't know how to.

Thanks,


Ofer Cohen said:
Try using code instead of a macro.
Using code you can use the Debug and step through the lines, and view each
value.

Something like

Dim MyCriteria As String
MyCriteria = "[hb] Like *" & [Forms]![searchHearB]![Ssearch] & "* Or [de]
Like *" & [Forms]![searchHearB]![Ssearch] & "*"

Docmd.OpenReport "ReportName" , , , MyCriteria

--
Good Luck
BS"D


ooxx said:
Hi all,

I need to write in procedure code when the macro is truncated the criteria.

I have two fields, and I would do in the macro on the subject of to open
report in print preview format and its where criteria as follows:
[hb] Like "*" & [Forms]![searchHearB]![Ssearch] & "*" Or [hb] Like
[Forms]![searchHearB]![Ssearch] & "*" Or [de] Like
[Forms]![searchHearB]![Ssearch] & "*" Or [de] Like "*" &
[Forms]![searchHearB]![Ssearch] Or [de] Like [Forms]![searchHearB]![Ssearch]
& "*"

I have problem to concatenate them in the code procedure.

I try from the simple but not success, the problem exists even it succeeds
in doing code format that Access can't find the field, though the fields
exists in the Report1.

Thans,
 
Try adding a single quote for the string

Dim MyCriteria As String
MyCriteria = "[hb] Like '*" & [Forms]![searchHearB]![Ssearch] & "*' Or [de]
Like '*" & [Forms]![searchHearB]![Ssearch] & "*'"

Docmd.OpenReport "ReportName" , , , MyCriteria


--
Good Luck
BS"D


ooxx said:
Hi,

I have test the code, but it gets bugs, and I can't fix. The problem is at
the "*" when concatenated on the last of the the sentence that it should be "
to close the sentence, but I don't know how to.

Thanks,


Ofer Cohen said:
Try using code instead of a macro.
Using code you can use the Debug and step through the lines, and view each
value.

Something like

Dim MyCriteria As String
MyCriteria = "[hb] Like *" & [Forms]![searchHearB]![Ssearch] & "* Or [de]
Like *" & [Forms]![searchHearB]![Ssearch] & "*"

Docmd.OpenReport "ReportName" , , , MyCriteria

--
Good Luck
BS"D


ooxx said:
Hi all,

I need to write in procedure code when the macro is truncated the criteria.

I have two fields, and I would do in the macro on the subject of to open
report in print preview format and its where criteria as follows:
[hb] Like "*" & [Forms]![searchHearB]![Ssearch] & "*" Or [hb] Like
[Forms]![searchHearB]![Ssearch] & "*" Or [de] Like
[Forms]![searchHearB]![Ssearch] & "*" Or [de] Like "*" &
[Forms]![searchHearB]![Ssearch] Or [de] Like [Forms]![searchHearB]![Ssearch]
& "*"

I have problem to concatenate them in the code procedure.

I try from the simple but not success, the problem exists even it succeeds
in doing code format that Access can't find the field, though the fields
exists in the Report1.

Thans,
 
no,not works
glitch

Ofer Cohen said:
Try adding a single quote for the string

Dim MyCriteria As String
MyCriteria = "[hb] Like '*" & [Forms]![searchHearB]![Ssearch] & "*' Or [de]
Like '*" & [Forms]![searchHearB]![Ssearch] & "*'"

Docmd.OpenReport "ReportName" , , , MyCriteria


--
Good Luck
BS"D


ooxx said:
Hi,

I have test the code, but it gets bugs, and I can't fix. The problem is at
the "*" when concatenated on the last of the the sentence that it should be "
to close the sentence, but I don't know how to.

Thanks,


Ofer Cohen said:
Try using code instead of a macro.
Using code you can use the Debug and step through the lines, and view each
value.

Something like

Dim MyCriteria As String
MyCriteria = "[hb] Like *" & [Forms]![searchHearB]![Ssearch] & "* Or [de]
Like *" & [Forms]![searchHearB]![Ssearch] & "*"

Docmd.OpenReport "ReportName" , , , MyCriteria

--
Good Luck
BS"D


:

Hi all,

I need to write in procedure code when the macro is truncated the criteria.

I have two fields, and I would do in the macro on the subject of to open
report in print preview format and its where criteria as follows:
[hb] Like "*" & [Forms]![searchHearB]![Ssearch] & "*" Or [hb] Like
[Forms]![searchHearB]![Ssearch] & "*" Or [de] Like
[Forms]![searchHearB]![Ssearch] & "*" Or [de] Like "*" &
[Forms]![searchHearB]![Ssearch] Or [de] Like [Forms]![searchHearB]![Ssearch]
& "*"

I have problem to concatenate them in the code procedure.

I try from the simple but not success, the problem exists even it succeeds
in doing code format that Access can't find the field, though the fields
exists in the Report1.

Thans,
 
What do you get? Is it an error or the report doesn't show the right records?

can you post the code you have?

--
Good Luck
BS"D


ooxx said:
no,not works
glitch

Ofer Cohen said:
Try adding a single quote for the string

Dim MyCriteria As String
MyCriteria = "[hb] Like '*" & [Forms]![searchHearB]![Ssearch] & "*' Or [de]
Like '*" & [Forms]![searchHearB]![Ssearch] & "*'"

Docmd.OpenReport "ReportName" , , , MyCriteria


--
Good Luck
BS"D


ooxx said:
Hi,

I have test the code, but it gets bugs, and I can't fix. The problem is at
the "*" when concatenated on the last of the the sentence that it should be "
to close the sentence, but I don't know how to.

Thanks,


:

Try using code instead of a macro.
Using code you can use the Debug and step through the lines, and view each
value.

Something like

Dim MyCriteria As String
MyCriteria = "[hb] Like *" & [Forms]![searchHearB]![Ssearch] & "* Or [de]
Like *" & [Forms]![searchHearB]![Ssearch] & "*"

Docmd.OpenReport "ReportName" , , , MyCriteria

--
Good Luck
BS"D


:

Hi all,

I need to write in procedure code when the macro is truncated the criteria.

I have two fields, and I would do in the macro on the subject of to open
report in print preview format and its where criteria as follows:
[hb] Like "*" & [Forms]![searchHearB]![Ssearch] & "*" Or [hb] Like
[Forms]![searchHearB]![Ssearch] & "*" Or [de] Like
[Forms]![searchHearB]![Ssearch] & "*" Or [de] Like "*" &
[Forms]![searchHearB]![Ssearch] Or [de] Like [Forms]![searchHearB]![Ssearch]
& "*"

I have problem to concatenate them in the code procedure.

I try from the simple but not success, the problem exists even it succeeds
in doing code format that Access can't find the field, though the fields
exists in the Report1.

Thans,
 
Yeah it works now.

Thanks the single quot works. It's my stupidity. :P

Ofer Cohen said:
What do you get? Is it an error or the report doesn't show the right records?

can you post the code you have?

--
Good Luck
BS"D


ooxx said:
no,not works
glitch

Ofer Cohen said:
Try adding a single quote for the string

Dim MyCriteria As String
MyCriteria = "[hb] Like '*" & [Forms]![searchHearB]![Ssearch] & "*' Or [de]
Like '*" & [Forms]![searchHearB]![Ssearch] & "*'"

Docmd.OpenReport "ReportName" , , , MyCriteria


--
Good Luck
BS"D


:

Hi,

I have test the code, but it gets bugs, and I can't fix. The problem is at
the "*" when concatenated on the last of the the sentence that it should be "
to close the sentence, but I don't know how to.

Thanks,


:

Try using code instead of a macro.
Using code you can use the Debug and step through the lines, and view each
value.

Something like

Dim MyCriteria As String
MyCriteria = "[hb] Like *" & [Forms]![searchHearB]![Ssearch] & "* Or [de]
Like *" & [Forms]![searchHearB]![Ssearch] & "*"

Docmd.OpenReport "ReportName" , , , MyCriteria

--
Good Luck
BS"D


:

Hi all,

I need to write in procedure code when the macro is truncated the criteria.

I have two fields, and I would do in the macro on the subject of to open
report in print preview format and its where criteria as follows:
[hb] Like "*" & [Forms]![searchHearB]![Ssearch] & "*" Or [hb] Like
[Forms]![searchHearB]![Ssearch] & "*" Or [de] Like
[Forms]![searchHearB]![Ssearch] & "*" Or [de] Like "*" &
[Forms]![searchHearB]![Ssearch] Or [de] Like [Forms]![searchHearB]![Ssearch]
& "*"

I have problem to concatenate them in the code procedure.

I try from the simple but not success, the problem exists even it succeeds
in doing code format that Access can't find the field, though the fields
exists in the Report1.

Thans,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top