I am building a library database, and this default value " Date Book was Borrowed + Day (21) " was working just fine (i think) , but I dont know what I did and whenever I try to place this default value in the "Ideal Date of Book Return" it gives a " 'mismatch' in the default value" when Im almost sure it worked in the past. What can I do to make the Ideal Date of Book Return be 3 weeks later than the date a book was borrowed. Its just so odd
A Table default value cannot reference another field in your table.
By putting
" Date Book was Borrowed + Day (21) "
in the Default property of a table field, you're trying to set the
date to THAT TEXT STRING - and " Date Book Was Borrowed + Day (21) "
is meaningful to a human reader, but not to a poor ignorant computer
program!
I would suggest that you need a little VBA code in the Form that
you're using to do the data entry. I presume you're comfortable with
using VBA code since you posted this message to the formscoding
newsgroup (if not post back for more details); just use the
AfterUpdate event of the [Date Book Was Borrowed] textbox with code
like
Private Sub Date_Book_Was_Borrowed_AfterUpdate()
If IsNull(Me!Ideal_Date_Of_Book_Return) Then
Me!Ideal_Date_Of_Book_Return = DateAdd("d", 21, _
Me!Date_Book_Was_Borrowed)
End If
End Sub
Just a suggestion: you'll find your code easier to read and maintain
if you use a naming convention and shorter fieldnames, without blanks
in them. You can always use Labels or the Caption property of fields
for human readability; but fieldnames like dtBorrowed and dtDue, bound
to textboxes txtdtBorrowed and txtdtDue, would make your code look
simpler.