0 at the beginning of string 
Author Message
 0 at the beginning of string

I have written a function which has this statement in it:

        Dim Mymonth As String, strSQL As String
        Mymonth = "0" & CStr(month(Date))
        strSQL = "UPDATE MyTable SET MyTable.month = " & ECDdate & ";"
        CurrentDb().Execute strSQL

But when I checked the field month in MyTable and it is 1 instead of 01.
When I put a "Msgbox Mymonth" command before strSQL= .... line, I see a
message of 01 which is what I want. How may I get 01 in my field instead
of 1.

Thanks



Tue, 09 Apr 2002 03:00:00 GMT  
 0 at the beginning of string
What type of field is MONTH in your table?


Quote:
> I have written a function which has this statement in it:

> Dim Mymonth As String, strSQL As String
>         Mymonth = "0" & CStr(month(Date))
> strSQL = "UPDATE MyTable SET MyTable.month = " & ECDdate & ";"
> CurrentDb().Execute strSQL

> But when I checked the field month in MyTable and it is 1 instead of 01.
> When I put a "Msgbox Mymonth" command before strSQL= .... line, I see a
> message of 01 which is what I want. How may I get 01 in my field instead
> of 1.

> Thanks



Tue, 09 Apr 2002 03:00:00 GMT  
 0 at the beginning of string

text

Quote:

> What type of field is MONTH in your table?



> > I have written a function which has this statement in it:

> > Dim Mymonth As String, strSQL As String
> >         Mymonth = "0" & CStr(month(Date))
> > strSQL = "UPDATE MyTable SET MyTable.month = " & ECDdate & ";"
> > CurrentDb().Execute strSQL

> > But when I checked the field month in MyTable and it is 1 instead of 01.
> > When I put a "Msgbox Mymonth" command before strSQL= .... line, I see a
> > message of 01 which is what I want. How may I get 01 in my field instead
> > of 1.

> > Thanks



Tue, 09 Apr 2002 03:00:00 GMT  
 0 at the beginning of string
your SLQ statement does NOT include MYMONTH -
change it to:
strSQL = "UPDATE MyTable SET MyTable.month = '" & Mymonth & "'"

1)NOTE the single quotes (') before and after the variable Mymonth
2) this will update EVERY record in the table since you have no WHERE clause

Quote:
>         Mymonth = "0" & CStr(month(Date))
> > strSQL = "UPDATE MyTable SET MyTable.month = " & ECDdate & ";"



Quote:

> text


> > What type of field is MONTH in your table?



> > > I have written a function which has this statement in it:

> > > Dim Mymonth As String, strSQL As String
> > >         Mymonth = "0" & CStr(month(Date))
> > > strSQL = "UPDATE MyTable SET MyTable.month = " & ECDdate & ";"
> > > CurrentDb().Execute strSQL

> > > But when I checked the field month in MyTable and it is 1 instead of
01.
> > > When I put a "Msgbox Mymonth" command before strSQL= .... line, I see
a
> > > message of 01 which is what I want. How may I get 01 in my field
instead
> > > of 1.

> > > Thanks



Tue, 09 Apr 2002 03:00:00 GMT  
 0 at the beginning of string
Quote:

>> What type of field is MONTH in your table?

On Fri, 22 Oct 1999 13:53:24 -0500, Arash Mahdian

Quote:

>text

But you're setting it using a numeric value:

Quote:
> strSQL = "UPDATE MyTable SET MyTable.month = " & ECDdate & ";"

if you print strSQL, you'll see it contains

  ...month = 010;

which will pass the number ten, which will be converted into the text
value "10" by the DB engine. I'm assuming that ECDate is a misprint
for myMonth

Try something like

 strSQL = "UPDATE MyTable SET MyTable.month = """ & myMonth & """;"

which will delimit the text value properly.

HTH

Tim F

--



Wed, 10 Apr 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Remove quote from Beginning of string

2. Add text to the beginning of an existing string

3. how to access a binary string, beginning with zero byte

4. how to access a binary string, beginning with zero byte

5. How to Insert a string at the beginning of a file

6. Appending string to the beginning of a file

7. Beginning and ending dates of a specified week

8. not sure where to begin

9. I am beginning to get frustrated :(

10. Beginning Access 2k VBA book question

11. Not too sure where to Begin MSAcess to Outlook

12. How to move to the beginning of a paragraph

 

 
Powered by phpBB® Forum Software