UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> put date from listbox into oneform    
 
   
cuongvt1976
post Feb 15 2005, 09:16 PM
Post #1

UtterAccess Member
Posts: 26



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
Go to the top of the page
 
+
cuongvt1976
post Feb 15 2005, 09:25 PM
Post #2

UtterAccess Member
Posts: 26



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
Go to the top of the page
 
+
R. Hicks
post Feb 15 2005, 09:25 PM
Post #3

UA Forum Administrator
Posts: 38,131
From: Birmingham, Alabama USA



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
Go to the top of the page
 
+
R. Hicks
post Feb 15 2005, 09:28 PM
Post #4

UA Forum Administrator
Posts: 38,131
From: Birmingham, Alabama USA



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
Go to the top of the page
 
+
spender
post Feb 15 2005, 09:32 PM
Post #5

UtterAccess Addict
Posts: 210
From: Birmingham UK



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
Go to the top of the page
 
+
cuongvt1976
post Feb 15 2005, 10:18 PM
Post #6

UtterAccess Member
Posts: 26



thank you very much for replies
I have changed birth and hiredo from date into variant. It works fine.
thanks again.
Go to the top of the page
 
+
R. Hicks
post Feb 15 2005, 10:21 PM
Post #7

UA Forum Administrator
Posts: 38,131
From: Birmingham, Alabama USA



You are very Welcome ... (IMG:http://www.utteraccess.com/forum/style_emoticons/default/wink.gif)

RDH
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 11:19 AM