Hello All,
I am currently trying to write a simple visual basic application (my first time using the language) which calls a userform with several textboxes. The information from these textboxes will eventually be used to generate a report. I am having some problems entering a date into one of these textboxes. What I would like to do is add a calculated number of days to this date and output a new date using DateAdd(). However I am getting a runtime error 13 type mismatch. I think this is because the date string is incorrectly formatted as my code works with NOW() replacing DischargeDate.
Here is my code
Please excuse any vulgarities in this code as it is my first time using VBA and I am unsure how to construct an application 'correctly'. I think the problem is that I enter a string corresponding to the date of discharge in the format dd/mm/yyyy into a text box. I then call DateDischarge = Me.tb_DateDischarge.Value which passes a string to the variable DischargeDate which i have defined Dim DischargeDate as Date. I then try to use the function DateAdd("d", ChildRestriction, DischargeDate) where ChildRestriction is an integer. I get a runtime error at this point I think because DischargeDate remains a string and not a date as required
How can I get around this issue?
Bookmarks