cuongvt1976
Feb 15 2005, 09:16 PM
here is mylistbox (of A form's load event):
With Me.deptsafetyList
.RowSource = _
" Select employeeid, Firstname, department, fullname, birth, hiredon from Employees " & _
" where department is not null " & _
" order by department,firstname "
.BoundColumn = 1
.ColumnHeads = True
.ColumnCount = 6
.ColumnWidths = "0.8 in;0;1.1 in;0.9 in;0;0"
.Requery
End With
End Select
on double click of inputbox event, I added this code:
Dim Emp As String
Dim brth As Date
Dim hiredo As Date
Emp = Me.deptsafetyList.Column(0)
brth = Me.deptsafetyList.Column(4)
hiredo = Me.deptsafetyList.Column(5)
DoCmd.OpenForm "accidentdetail", acNormal
DoCmd.GoToRecord , , acNewRec
Forms!accidentdetail!EmployeeID = Emp
Forms!accidentdetail!birth = brth
Forms!accidentdetail!Hiredon = hiredo
But when I double clicked on listbox, "type missmatch" error appeared.
Could you helped me to solve the problem?
please helped me, I need your help. Many thanks
cuongvt1976
Feb 15 2005, 09:25 PM
I found the problem:
My code is true (when I double clicked in the listbox, the accident detail form is opened with no problem) if in my listbox (not inputbox, sorry for my typing mistake) birth and hiredon is not null, if one of them is null, "type missmatch" error appeared.
So, how can I handle this error when I double click my listbox, it still open accident detail form, and leave birth and hiredon textbox in this form blank?
many thanks
R. Hicks
Feb 15 2005, 09:25 PM
Hmmmmm ....
In your code you have:
Emp = Me.deptsafetyList.Column(0)
"Column(0) is the "employeeid" from the table .. I would assume that to be a Numeric value and you have "Emp" dimmed as a String variable ...
That should not cause the error though ...
Is it possible that the recordset is returning Null values (fields with no data) ???
If there are Nulls being returned and you have all of the variables dimmed as Strings .. that will create the error you are receiving.
A String can not store a Null value ...
RDH
R. Hicks
Feb 15 2005, 09:28 PM
If you have Null or Empty value in your fields ...
You will either have to assign these values to variables dimmed as Variants ...
or ... convert the Null values to something other than a Null ...
RDH
spender
Feb 15 2005, 09:32 PM
Hi
From your own diagnosis I would suggest trying changing the following lines of code to:-
CODE
brth =Nz( Me.deptsafetyList.Column(4),"")
hiredo = Nz(Me.deptsafetyList.Column(5),"")
HTH
cuongvt1976
Feb 15 2005, 10:18 PM
thank you very much for replies
I have changed birth and hiredo from date into variant. It works fine.
thanks again.
R. Hicks
Feb 15 2005, 10:21 PM
You are very Welcome ...

RDH
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.