473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

unbound and null

23
i've used for data entry some unbound text boxes
they are of number, date/time



user will enter data into these fields; when click 'Add New' button,
rs will update and these unbound controls to be cleared by assinging 'null' value to it; but when i click 'add new' button i get an error like this:

"you tried to assign the Null value to a variable that is not a Variant data type"

pls help me
thanks
Dec 9 '06 #1
17 2369
MMcCarthy
14,534 Expert Mod 8TB
Sorry Kaib

You will have to post the code behind the add new button and tell us what line is highlighted when the code stops.

Mary
Dec 9 '06 #2
ADezii
8,834 Expert 8TB
i've used for data entry some unbound text boxes
they are of number, date/time



user will enter data into these fields; when click 'Add New' button,
rs will update and these unbound controls to be cleared by assinging 'null' value to it; but when i click 'add new' button i get an error like this:

"you tried to assign the Null value to a variable that is not a Variant data type"

pls help me
thanks
'I'll assume the Unbound Controls into which you are entering data are Text
'Boxes. Do not attempt to clear them out by assigning the Null value to them, but rather the vbNullStyring or the empty string ("") e.g.
Expand|Select|Wrap|Line Numbers
  1. Me![txtTest].Text = vbNullString 
  2.                  OR
  3. Me![txtTest].Text = ""
Hope this helps..
Dec 10 '06 #3
NeoPa
32,556 Expert Mod 16PB
I'm not sure that's right ADezii.
I think this is referring to a DIMmed variable in the code. Most form controls take Nulls ok. Even Record Fields are likely to (depending on set up rather simply their type).
We need to go back to Mary's post and request the user posts the relevant code used.
Dec 10 '06 #4
kaib
23
scenario is like this:

i put some unbound controls in header of a continous form; after user enters the data when he [press 'add new' unbound cntrols are cleared and down records are added; but two controls one is combo which look the em[ployee names into
em[p.master file; another is a calendar ocx; the rest are normal text boxes;
below the code given under 'add new'; how can i clear the value of combo and calendar;(both used for the easy data entry)

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_add_Click()
  2. On Error GoTo Err_cmd_Add_Click
  3. Dim db As DAO.Database
  4. Dim rs As DAO.Recordset
  5. Dim strsql As String
  6.     Set db = CurrentDb
  7.     Set rs = db.OpenRecordset("time_entry", dbOpenDynaset)
  8.     rs.AddNew
  9.         'rs!ref_id = Me.txt_ref
  10.         rs!EMP_CODE = Me.EMP_CODE
  11.         rs!WORK_DATE = Me.Calendar2
  12.         rs!START = Me.txt_start
  13.         rs!LUNCH_OUT = Me.txt_lunchout
  14.         rs!LUNCH_IN = Me.txt_lunchin
  15.         rs!L_END = Me.txt_L_END
  16.         rs!TOT_HRS = Me.txt_totalhrs
  17.         rs!WORK_HRS = Me.tot_wkd_hrs
  18.         rs!REG_HRS = Me.txt_reg_hrs
  19.         rs!OT_HRS = Me.OTHRS
  20.  
  21.  
  22.     rs.Update
  23.  
  24.     'Me.txt_ref.Text = ""
  25.  
  26.     Me.txt_start.Text = ""
  27.     Me.txt_lunchout.Text = ""
  28.     Me.txt_lunchin.Text = ""
  29.     Me.txt_L_END.Text = ""
  30.     Me.txt_totalhrs.Text = ""
  31.     Me.tot_wkd_hrs.Text = ""
  32.     Me.txt_reg_hrs.Text = ""
  33.     Me.OTHRS.Text = ""
  34.  
  35.  
  36.     Me.Requery
  37.  
  38. Exit_cmd_Add_Click:
  39.     Exit Sub
  40.  
  41. Err_cmd_Add_Click:
  42.     If Err.Number = 3315 Then 'zero-length string
  43.         Resume Exit_cmd_Add_Click
  44.     Else
  45.         MsgBox Err.description
  46.         Resume Exit_cmd_Add_Click
  47.     End If
  48.  
  49. End Sub
now when click add new button i get the following error:
"you cannot reference a [pro[perty or method for a control unless the control has the focus"

i did n't get it [pro[perly!
below the code for the validation so that user cannot enter duplicate time and attendance for a particular employee on same workdate; the thing is getting highlighted is in italics in code;
-----------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. Dim strWhere As String
  3. Dim varResult As Variant
  4. Dim strMsg As String
  5.  
  6. If IsNull(Me.EMP_CODE) Or IsNull(Me.WORK_DATE) Or _
  7. (Me.EMP_CODE  = Me.EMP_CODE.OldValue And _
  8. Me.Calendar2 = Me.Calendar2.OldValue) Then
  9. 'do nothing
  10. Else
  11.  
  12. strWhere = "([WORK_DATE] = " & Format(Me.Calendar2, "\#mm/dd/yyyy\#") & ") " & _
  13. " AND ([emp_code] = " & Me.EMP_CODE & ")"
  14.  
  15. 'strWhere = "([calendar5] = """ & Me.Calendar5 & _
  16. '""") AND ([emp_code] = """ & Me.EMP_CODE & """)"
  17.  
  18. varResult = DLookup("ref_id", "time_entry", strWhere)
  19.  
  20. If Not IsNull(varResult) Then
  21. strMsg = "Record " & varResult & " in the table has the same name." & _
  22. vbCrLf & "Undo record?"
  23.  
  24. If MsgBox(strMsg, vbOKOnly, "Dulicate Entry") = vbOK Then
  25.  
  26. 'If MsgBox(strMsg, vbYesNo + vbDefaultButton2, _
  27. '"Possible duplicate") <> vbYes Then
  28. Cancel = True
  29. Me.Undo
  30. End If
  31. End If
  32. End If
  33. End Sub
Dec 10 '06 #5
NeoPa
32,556 Expert Mod 16PB
You refer to Me.WORK_DATE on that line but nowhere else.
I would guess that WORK_DATE is a table field and not an entry on your form.
Expand|Select|Wrap|Line Numbers
  1. If IsNull(Me.EMP_CODE) Or IsNull(Me.WORK_DATE) Or _
  2. (Me.EMP_CODE  = Me.EMP_CODE.OldValue And _
  3. Me.Calendar2 = Me.Calendar2.OldValue) Then
  4. 'do nothing
Dec 10 '06 #6
kaib
23
yes work_date is a table field; so how can i get rid of this error
help appreciated
thanks
Dec 11 '06 #7
NeoPa
32,556 Expert Mod 16PB
yes work_date is a table field; so how can i get rid of this error
help appreciated
thanks
So let me get this straight, you know the problem but you can't work out what to do to fix it?
How far have you got?
I want to avoid spoon-feeding you, you see. This does seem a little basic.
Dec 11 '06 #8
kaib
23
is it because the values are cleared! the validation doesn't work; i'm lost
help appreciated
thanks
Dec 11 '06 #9
NeoPa
32,556 Expert Mod 16PB
You need to replace Or IsNull(Me.WORK_DATE) with Or IsNull(Me.Calendar2).
Expand|Select|Wrap|Line Numbers
  1. If IsNull(Me.EMP_CODE) Or IsNull(Me.Calendar2) Or _
  2. (Me.EMP_CODE  = Me.EMP_CODE.OldValue And _
  3. Me.Calendar2 = Me.Calendar2.OldValue) Then
  4. 'do nothing
Dec 11 '06 #10
kaib
23
i tried but it doesn't work; i understand something; the error "you cannot reference a property or method for a control unless the control has the focus"

i remmed all the validation codes and still this error showing up! is it anywhere the ME is losing its focus! id don't understand...it doesn't come as highlighted instead with a heading micrsoft access;
i'm stuck
Dec 11 '06 #11
NeoPa
32,556 Expert Mod 16PB
You mean that error's fixed but you have another one?
Dec 11 '06 #12
MMcCarthy
14,534 Expert Mod 8TB
i tried but it doesn't work; i understand something; the error "you cannot reference a property or method for a control unless the control has the focus"

i remmed all the validation codes and still this error showing up! is it anywhere the ME is losing its focus! id don't understand...it doesn't come as highlighted instead with a heading micrsoft access;
i'm stuck
If you click debug it should show the line of code highlighted in yellow that has the problem.

Mary
Dec 11 '06 #13
kaib
23
You mean that error's fixed but you have another one?
in fact i want a validataion before rs.update if for one employee duplicate workdates are entered; i remmed my code under Form_BeforeUpdate so there are no errors; but i lost my validation
could u assisit me validating these dates....!
thanks
Dec 12 '06 #14
NeoPa
32,556 Expert Mod 16PB
Try putting the
Expand|Select|Wrap|Line Numbers
  1. If IsNull(Me.EMP_CODE) Or IsNull(Me.Calendar2) Or _
  2. (Me.EMP_CODE  = Me.EMP_CODE.OldValue And _
  3. Me.Calendar2 = Me.Calendar2.OldValue) Then
  4. ...
before your rs.AddNew line.
YOU will have to work out how to do that properly. It's not difficult.
BTW your Form_BeforeUpdate was never triggered because you weren't doing the add via the bound form.
Dec 12 '06 #15
kaib
23
Try putting the
Expand|Select|Wrap|Line Numbers
  1. If IsNull(Me.EMP_CODE) Or IsNull(Me.Calendar2) Or _
  2. (Me.EMP_CODE  = Me.EMP_CODE.OldValue And _
  3. Me.Calendar2 = Me.Calendar2.OldValue) Then
  4. ...
before your rs.AddNew line.
YOU will have to work out how to do that properly. It's not difficult.
BTW your Form_BeforeUpdate was never triggered because you weren't doing the add via the bound form.
i keep trying but nothing work out
Dec 14 '06 #16
NeoPa
32,556 Expert Mod 16PB
i keep trying but nothing work out
Kaib,

You keep asking questions but you never seem to pass any info back.
What have you tried and where did it fail.
You seem to think it is our job to do all the chasing while you sit back and just pick up the results.
Without some signs that you are doing some work to help your own situation I'm not prepared to run around after you like one of my children when they were young enough to need it.
This is your problem and we are helpers. Not the other way around.
Show what you are doing and where your understanding needs help and we will help.
Dec 14 '06 #17
kaib
23
Kaib,

You keep asking questions but you never seem to pass any info back.
What have you tried and where did it fail.
You seem to think it is our job to do all the chasing while you sit back and just pick up the results.
Without some signs that you are doing some work to help your own situation I'm not prepared to run around after you like one of my children when they were young enough to need it.
This is your problem and we are helpers. Not the other way around.
Show what you are doing and where your understanding needs help and we will help.
thanks for ur comments; it's working now; but i gave up the DAO method
ur help is not misused; rather respected & valued
thanks again
Dec 14 '06 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal...
3
by: scott_baird | last post by:
Probably something simple, but it's driving me up the wall... In a report, I have an unbound control that is the total of 2 other bound controls (currency) as follows: unbound control =cash1 +...
31
by: DWolff | last post by:
I'm somewhat new to Access, and have no VB experience at all (except for modifying existing code where obvious). I built a data entry form that works fine. Typically, a client will call in and...
1
by: Martin | last post by:
Hi, I'm having a problem with a datagridview control when trying to read the value of an unbound checkbox cell. The code below works fine if I click on any text cell, bound or unbound, and...
2
by: Kevin Walzer | last post by:
I am trying to structure a Tkinter application with classes instead of just with simple functions, but I'm not sure how to call methods from my main class. My main class is packetstreamApp()....
30
by: Jess | last post by:
Hello, I tried a program as follows: include<iostream> using namespace std; class A{ public:
2
by: ccsnavy | last post by:
For some reason referencing an unbound control on an active form from a query has ceased to work correctly. While other previously existing references to unbound controls in the same form seem to...
12
by: dmcp | last post by:
i have an unbound form with 2 multiselect list boxes. grp & io. the IO listbox is unbound and depends on the grp listbox but after finishing from the grp listbox i'm getting a null IO listbox. the...
7
by: HSXWillH | last post by:
I am designing an inventory system and am stuck on a potential problem. I have a table of Stock_Catalog containing the following fields: Stock_ID (random autonumber), Full_Desc, Serial, Auto,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.