In my main menu form I have provided a button to check the tasks due as a reminder. In this assigned to field is coming as number , because in in my table it is of number type & it is linked to contact table to retrieve the data. So in my message box I need this number to be converted as the data stored my contact table. & also I can't increase the size of the message box so it is looking messy. please go through the attached images and code & help me.[table][messagebox[]][datatype restriction`
Option Compare Database
Private Sub cmdreminder_Click()
Dim RS As DAO.Recordset
Dim strMsg As String
Set RS = CurrentDb.OpenRecordset("Tasks", dbOpenSnapshot, dbReadOnly)
With RS
If Not (.BOF And .EOF) Then
.MoveFirst
While Not .EOF
If ![Due Date] >= Date - 7 Then
strMsg = strMsg & ![Title] & vbTab & vbTab & vbTab & ![Assigned to] & vbTab & vbTab & vbTab & ![Due Date] & vbCrLf
End If
.MoveNext
Wend
End If
.Close
End With
Set RS = Nothing
If strMsg <> "" Then
strMsg = "The following Tasks are due!!!:" & vbTab & vbTab & vbCrLf & vbCrLf &"-----------" & vbCrLf &"Equipment Name" & vbTab & vTab & "Agency Name" & vTab & vbTab & "Due Date" & vbCrLf &"----" & vbCrLf & strMsg Else strMsg = "No Tasks is pending" End If MsgBox strMsg, vbInformation + vbOKOnly End Sub ``]
To display the task description, you need to change the datasource of the recordset from Tasks
to a SQL query where you join the Tasks table with the Contact table using the task id.
Obviously I don't know the names of your table fields, but it should be something like this:
SELECT Tasks.*, Contacts.TaskDescription
FROM Tasks INNER JOIN Contacts ON Tasks.Id = Contacts.TaskId
As for styling the MessageBox, your options are limited. I would suggest to create your own Form that acts like a MessageBox.
There are plenty of examples on how to do this.