Problem with "Me(textfield).Value =" still displaying blank

B

Banaticus

Thanks.

It's not currently writing anything in the cells. I believe the problem is
in the " Do Until rst.EOF" loop, as I'm getting blank cells at the end,
although I've gone back and forth over that loop and its neighbors and I
can't for the life of me see why the cells would all be blank at the end.
The initial " 'clear all values in cells" loop in ClockImage_Click() works
well, I've tested it out seperately.
Code:
Private Sub SetDays()
Dim intI As Integer, intJ As Integer, strNum As String

' First, clear all the boxes
For intI = 1 To 42
' Controls are named "lblnn" and "txtnn"
' Where nn = 01 to 42
' Using Format to get 2 digits
strNum = Format(intI, "00")
' Clear the day number
Me("lbl" & strNum).Caption = ""     'If I change this to Caption =
"something here"
'The Caption is indeed
changed to "something here"
' Clear the contents of the text box
Me("txt" & strNum).Value = ""
' Grey out the background
Me("txt" & strNum).BackColor = 12632256
' And disable it
Me("txt" & strNum).Enabled = False
Next intI

intMonth = Me!theMonth
intYear = Me!theYear
' The first box to set it the weekday of the first day of the month
intFirst = Weekday(DateSerial(intYear, intMonth, 1), vbSunday)
' Calculate the last day number
intLastDay = Day(DateAdd("m", 1, DateSerial(intYear, intMonth, 1)) - 1)
' ... and the last box to set
intLast = intFirst + intLastDay - 1

' Now set up all the boxes for the current month
intJ = 1
For intI = intFirst To intLast
strNum = Format(intI, "00")
' Put the day number in the associated label caption
Me("lbl" & strNum).Caption = intJ
' Make the background of the box white
Me("txt" & strNum).BackColor = 16777215
' and Enable it
Me("txt" & strNum).Enabled = True
intJ = intJ + 1
Next intI

' Hide the last row if we didn't use it
If intLast < 36 Then
intJ = False
Else
intJ = True
End If
For intI = 36 To 42
Me("txt" & intI).Visible = intJ
Next intI
End Sub
Private Sub ClockImage_Click()
SetDays
Dim db As DAO.Database, rst As DAO.Recordset
Dim datFirstDate As Date, datLastDate As Date, strSQL As String
Dim intStart As Integer, intEnd As Integer, intI As Integer, strNum As String

' Clear all the text boxes
For intI = 1 To 42
strNum = Format(intI, "00")
Me("txt" & strNum).Value = ""
Next intI

' Get a pointer to the current database
Set db = CurrentDb

' Calculate the start and end date for the current month
datFirstDate = DateSerial(intYear, intMonth, 1)
datLastDate = DateSerial(intYear, intMonth, intLastDay)

' Set up to select the apppointments that are in
'  the current month
strSQL = "SELECT * FROM [CalendarInfo] WHERE [SocSec] = " &
Forms![Apprentice Information]![Soc Sec #] & " AND [StartDate] <= #" &
datLastDate & "# AND [EndDate] >= #" & datFirstDate & "#;"

Set rst = db.OpenRecordset(strSQL)

' Loop through all the rows and set the appointments in the calendar
Do Until rst.EOF
' Calculate the start point
If rst!StartDate < datFirstDate Then
intStart = intFirst
Else
intStart = Day(rst!StartDate) + intFirst - 1
End If
' Calculate the end point
If rst!EndDate > datLastDate Then
intEnd = intLast
Else
intEnd = Day(rst!EndDate) + intFirst - 1
End If

' Set the appropriate note in the appropriate days
For intI = intStart To intEnd
strNum = Format(intI, "00")
Me("txt" & strNum).Value = "Hi" 'Me("txt" & strNum).Value &
rst!Note
Next intI

' Get the next row
rst.MoveNext
Loop
rst.Close
End Sub
Code:
SocSec      StartDate Note           EndDate
561-45-6184 2/14/2006 Something Blah 2/16/2006
If, just above the End
Sub, I put:
Code:
For intI = 1 To 42
strNum = Format(intI, "00")
' Clear the day number
Me("txt" & strNum).Value = "lol"
Next intI
the value of the cells is Not set to "lol". Their stubborn refusal to laugh
is making a laughing mockery of me.
 

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

Top