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. -
Dim sqltext As String
-
-
'---- Form datasource
-
sqltext = "Select * from confattntracktest " & _
-
"where acyear=" & Me.cbxAcYear & _
-
" and rotation=" & Me.cbxMonth & _
-
" and conference='" & Me.cbxConfType & "'" & _
-
" and hospital='" & Me.cbxHosp & "'"
-
Me.RecordSource = sqltext
-
Me.txtAcYear.DefaultValue = Me.cbxAcYear
-
Me.txtMonth.DefaultValue = Me.cbxMonth
-
Me.txtConference.DefaultValue = Me.cbxConfType
-
Me.txtHosp.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 hospital=" & Me.cbxHosp & "' " & _
-
" order by 2"
-
Me.ComboResident.RowSource = sqltext
-
Me.Refresh
-
Me.Detail.Visible = True
-
End Sub
8 1747
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?
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?
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.
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
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.
I will try this - thanks so much.
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
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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 ...
|
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...
|
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...
|
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......
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
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,...
|
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,...
|
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: 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...
|
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...
|
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,...
| |