Write VB code to update table field

rockyjr

Registered User.
Local time
Today, 10:53
Joined
Mar 12, 2008
Messages
100
Hi everyone,

I dont know if anyone could help me on this one.

I would like to write some VB to update a field in a table. My table is like this.
table name : DepDates
Field names: ID, sDate, and sDateF

I have a report and the dates comes out as follows: Saturday, April 10th, 2012.

I was recently ask to bring out the report, but bilingual (French and English).

So, I created the field "sDateF" and thought if I could convert the "sDate" and update "sDateF" it would be simple.

I have a function that translate "Saturday" to "samedi" and same for weekdays called "sGetFrench". That works great if I do it on a form and edit a text field.

Anyways, how would I go about this and update all entries in my table using VB?

Many thanks,

LucS
 
You should not store this value in any table field, just display it in a calculated field in a query, or in a calculated control on a form or report. You may be able to modify your current function to return what you want. Then just call the function where you need it. Here is an example of a simple function that would return the date in French;

Code:
Function fnFrenchDate(dteMyDate As Date) As String

Dim sWeekDay As String
Dim sMonth As String

Select Case Weekday(dteMyDate)
    Case 1
        sWeekDay = "dimanche"
    Case 2
        sWeekDay = "lundi"
    Case 3
        sWeekDay = "mardi"
    Case 4
        sWeekDay = "mercredi"
    Case 5
        sWeekDay = "jeudi"
    Case 6
        sWeekDay = "vendredi"
    Case 7
        sWeekDay = "samedi"
End Select

Select Case Month(dteMyDate)
    Case 1
        sMonth = "janvier"
    Case 2
        sMonth = "février"
    Case 3
        sMonth = "mars"
    Case 4
        sMonth = "avril"
    Case 5
        sMonth = "mai"
    Case 6
        sMonth = "juin"
    Case 7
        sMonth = "juillet"
    Case 8
        sMonth = "août"
    Case 9
        sMonth = "septembre"
    Case 10
        sMonth = "octobre"
    Case 11
        sMonth = "novembre"
    Case 12
        sMonth = "décembre"
End Select

fnFrenchDate = sWeekDay & ", le " & Day(dteMyDate) & " " & sMonth & " " & Year(dteMyDate)
 
End Function

Returns values like;

dimanche, le 25 décembre 2011

I just threw this together so if you want to use it just check the spelling and that it returns what you want.
 
Ah ok ok, I see. I will give this a try. Thank you!
 

Users who are viewing this thread

Back
Top Bottom