473,396 Members | 1,998 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,396 software developers and data experts.

serious help - #Name error in txtHosp whenever this code is ran

46
I am trying to get rid of the #Name error that appears in my txtHosp text box when I run this code. the code below is also a call command, so any time I am updating a combo box, the following error appears in my textbox. I noticed that when I removed the code line:
Me.RecordSource = sqltext it takes it away and works fine, however then my other comboboxes do not load appropriately. seems like i'm overlooking something very obvious and i can't seem to find it.
Expand|Select|Wrap|Line Numbers
  1. Dim sqltext As String
  2.  
  3.     '---- Form datasource
  4.    sqltext = "Select * from confattntracktest " & _
  5.         "where acyear=" & Me.cbxAcYear & _
  6.         " and rotation=" & Me.cbxMonth & _
  7.         " and conference='" & Me.cbxConfType & "'" & _
  8.         " and hospital='" & Me.cbxHosp & "'"
  9.   Me.RecordSource = sqltext
  10.     Me.txtAcYear.DefaultValue = Me.cbxAcYear
  11.     Me.txtMonth.DefaultValue = Me.cbxMonth
  12.     Me.txtConference.DefaultValue = Me.cbxConfType
  13.     Me.txtHosp.DefaultValue = Me.cbxHosp
  14.     '---- Resident box datasource
  15.     sqltext = "select eid,dbo.idtoname(eid) resname " & _
  16.         "from schedule s,serviceward w " & _
  17.         "where stfgroup in (3,4) " & _
  18.         "and rotation=" & Me.cbxMonth & _
  19.         " and acyear=" & Me.cbxAcYear & _
  20.         " and s.srvcode=w.srvcode " & _
  21.         " and hospital=" & Me.cbxHosp & "' " & _
  22.         " order by 2"
  23.     Me.ComboResident.RowSource = sqltext
  24.     Me.Refresh
  25.     Me.Detail.Visible = True
  26. End Sub
Apr 30 '07 #1
8 1747
MMcCarthy
14,534 Expert Mod 8TB
Me.RecordSource = sqltext

This changes the record source of your form. So I believe the problem is that the value being obtained by selecting cbxHosp is not returning the value you want. What is the datatype of the hospital field in your table?
May 1 '07 #2
teneesh
46
the data type of hospital in my table is Char. Length = 2.
should I change it to something else?


Me.RecordSource = sqltext

This changes the record source of your form. So I believe the problem is that the value being obtained by selecting cbxHosp is not returning the value you want. What is the datatype of the hospital field in your table?
May 1 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
the data type of hospital in my table is Char. Length = 2.
should I change it to something else?
Assuming this is a SQL backend.

Check the linked table in design view and see how Access is interpreting this field as Access doesn't have a char datatype.
May 1 '07 #4
teneesh
46
yes, backend is sql, where datatype is char, but its also displaying as char in access for the design of the table. however i did just notice that the allow nulls checkbox was checked and it should not be. when i unchecked it, i get another error stating that null values cannot be inserted into the table. 'insert fails'
please advise. thanks
May 1 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
yes, backend is sql, where datatype is char, but its also displaying as char in access for the design of the table. however i did just notice that the allow nulls checkbox was checked and it should not be. when i unchecked it, i get another error stating that null values cannot be inserted into the table. 'insert fails'
please advise. thanks
Can you change the datatype of the sql to varchar as Access will interpret this as a string. I think it's having a problem interpreting the char datatype.

Essentially you can't make design changes to a linked table in Access they will have to be made in the backend.
May 1 '07 #6
teneesh
46
I will try this - thanks so much.
May 1 '07 #7
teneesh
46
sending what worked:
I was missing the quotes around cbxHosp.

Sub PopulateData()
Dim sqltext As String
'---- Form datasource
sqltext = "Select * from confattntrack " & _
"where acyear=" & Me.cbxAcYear & _
" and rotation=" & Me.cbxMonth & _
" and conference='" & Me.cbxConfType & "'" & _
" and hosp='" & Me.cbxHosp & "'"
Me.RecordSource = sqltext
Me.txtAcYear.DefaultValue = Me.cbxAcYear
Me.txtMonth.DefaultValue = Me.cbxMonth
Me.txtConference.DefaultValue = Me.cbxConfType
Me.ComboHosp.DefaultValue = "'" & Me.cbxHosp & "'"

'---- Resident box datasource
sqltext = "select eid,dbo.idtoname(eid) resname " & _
"from schedule s,serviceward w " & _
"where stfgroup in (3,4) " & _
"and rotation=" & Me.cbxMonth & _
" and acyear=" & Me.cbxAcYear & _
" and s.srvcode=w.srvcode " & _
"and hosp='" & Me.cbxHosp & "' " & _
" order by 2"
Me.ComboResident.RowSource = sqltext
Me.Refresh
Me.Detail.Visible = True
End Sub
May 1 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
Glad you got it working. You shouldn't have needed the quotes on the default value setting but this is obviously getting around the fact the Access can't recognise the char value.

If it works it works :D
May 1 '07 #9

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

Similar topics

3
by: John Draper | last post by:
I am having a lot of problems trying to get a Python CGI to run. I have included 3 parts... 1) A simple stripped down python module. 2) An output of what I get when I do: python index.py...
2
by: CxG | last post by:
We need to copy about 25 databases whenever we get a new software delivery. Currently, the process is to manually use the DTS database copy wizard. Doing some research, I created a DTS package...
142
by: Herr Lucifer | last post by:
As the founder of .NET framework, Microsoft claims that it invention will be the next best platform for programming in a near future. Now it is 2005, ..NET is 5 years old, and can talk and walk for...
0
by: Joseph | last post by:
I've encountered a DB2 error that seems to be quite serious. This is from DB2 7.2.5 running on Windows 2000 Server. Here are the entries from the db2diag.log file (with database name changed per...
10
by: kiran_s_rao | last post by:
I have a serious issue that seems to be intermittent with User.Identity.Name. In an environment where about 100+ users are logging on to a site with forms authentication, calling ...
1
by: kath | last post by:
Hello, sorry about the lengthy message. I finding difficult to execute this program. The wx.Notebook i created is coming on the splitted frame(self.p2). How do I that. I am started to learn...
1
by: vijay.db | last post by:
Hi Team, Very serious problem with my DB2 V8.1 Fixpack 6 running in AIX 5.1 machine. Every one hour my DB2 instance processes are killed and it's going down. Several trap files are generated in...
10
by: Rob | last post by:
I am reading a book that says that the "name" property can be altered only at design time and cannot be modified at runtime. Please explain this given the code below... If you click Button3......
1
by: Johnson545236 | last post by:
I need some serious help. I'm extremely new to vs 2003 .net and I have to work with CRM, sigh. I am trying my first program and I get this error: Description: An error occurred during the...
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: 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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.