Some Quotation Mark

  • Thread starter Thread starter a
  • Start date Start date
A

a

This code support only (Numeric value) can any one covert this code to
accept (text value)

==================================

The code

If DCount("[GoupNumber]", "TblAccomodation", "[GoupNumber] = " &
Me.GroupNumber) > 0 Then

DoCmd.OpenForm "frmaccomodation", , , "([GoupNumber]=" & Me.GroupNumber &
")"

===================================

I think I need some quotation mark but I don't know where can I put them

Thank you
 
a said:
This code support only (Numeric value) can any one covert this code to
accept (text value)

==================================

The code

If DCount("[GoupNumber]", "TblAccomodation", "[GoupNumber] = " &
Me.GroupNumber) > 0 Then

DoCmd.OpenForm "frmaccomodation", , , "([GoupNumber]=" & Me.GroupNumber &
")"

===================================

I think I need some quotation mark but I don't know where can I put them

Thank you

Dim strCriteria As String

strCriteria = "[GoupNumber] ='" & Me.GroupNumber & "'"

If DCount("[GoupNumber]", "TblAccomodation", strCriteria) Then
DoCmd.OpenForm "frmaccomodation", , , strCriteria
End If
 
Thank you for your time

Thank you very much the code work very good

But can you demonstrate the code for me

Give me some comment to understand

How the code work?



Dim strCriteria As String

strCriteria = "[GoupNumber] ='" & Me.GroupNumber & "'"

If DCount("[GoupNumber]", "TblAccomodation", strCriteria) Then
DoCmd.OpenForm "frmaccomodation", , , strCriteria
End If



Stuart McCall said:
a said:
This code support only (Numeric value) can any one covert this code to
accept (text value)

==================================

The code

If DCount("[GoupNumber]", "TblAccomodation", "[GoupNumber] = " &
Me.GroupNumber) > 0 Then

DoCmd.OpenForm "frmaccomodation", , , "([GoupNumber]=" & Me.GroupNumber &
")"

===================================

I think I need some quotation mark but I don't know where can I put them

Thank you

Dim strCriteria As String

strCriteria = "[GoupNumber] ='" & Me.GroupNumber & "'"

If DCount("[GoupNumber]", "TblAccomodation", strCriteria) Then
DoCmd.OpenForm "frmaccomodation", , , strCriteria
End If
 
a said:
Thank you for your time

Thank you very much the code work very good

But can you demonstrate the code for me

Give me some comment to understand

How the code work?



Dim strCriteria As String

strCriteria = "[GoupNumber] ='" & Me.GroupNumber & "'"

If DCount("[GoupNumber]", "TblAccomodation", strCriteria) Then
DoCmd.OpenForm "frmaccomodation", , , strCriteria
End If



Stuart McCall said:
a said:
This code support only (Numeric value) can any one covert this code to
accept (text value)

==================================

The code

If DCount("[GoupNumber]", "TblAccomodation", "[GoupNumber] = " &
Me.GroupNumber) > 0 Then

DoCmd.OpenForm "frmaccomodation", , , "([GoupNumber]=" & Me.GroupNumber
& ")"

===================================

I think I need some quotation mark but I don't know where can I put them

Thank you

Dim strCriteria As String

strCriteria = "[GroupNumber] ='" & Me.GroupNumber & "'"

If DCount("[GoupNumber]", "TblAccomodation", strCriteria) Then
DoCmd.OpenForm "frmaccomodation", , , strCriteria
End If

Ok, apologies for being terse in my response. The reason I used a string
variable (strCriteria) was to avoid squeezing everything into the Dcount
line. Makes it more readable and maintainable. This code:

strCriteria = "[GroupNumber] ='"

inserts an apostrophe just before we insert the value:

& Me.GroupNumber

Then this part:

& "'"

provides the matching apostrophe, following the value. When this variable is
evaluated at runtime, (assuming GroupNumber is "ABC123") it is seen as:

"[GroupNumber] ='ABC123'

Then, because the criteria required for both the Dcount and DoCmd calls is
the same, we use strCriteria in both places (I think of these situations as
"one to many" - sound familiar? ie the code is created once and used more
than once - many)

Does that help any?
 
Back
Top