Hi,
I have a problem that had me going around in circles for days now.
I have a combo box which updates from another combo box correctly. I'm now trying to get trying to get a text box to display a value based on the selection from the second combo box. My after event code is: - Private Sub cboActivity_AfterUpdate()
-
Me.cboRateHigh = DLookup("ProductivityRateHigh", "tblUnitPeriod", "ID= ' " & Me.cboActivity & " ' ")
-
End Sub
ID is the primary key and a number. The value returned in the combo box is text. I think this is where the issue is, because for some reason the Combo box doesn't seem show the PK (number) if I display the other columns.
I'm currently getting a run-time error 3464 'Data type mismatch in criteria expression'.
Thanks in advance for the help.
6 1447 twinnyfo 3,653
Recognized Expert Moderator Specialist
Not to mention that your quotes are including extra spaces on each side of your Combo Box's value, so, even if it could have been able to find that value taken as a string (which it might), you were looking for the wrong value in the first place.
As NeoPa suggests, your proper syntax should be: - Me.cboRateHigh = _
-
DLookup("ProductivityRateHigh", _
-
"tblUnitPeriod", _
-
"ID=" & Me.cboActivity)
However, this assumes that the Combo Box's bound column is the Primary Key.
NeoPa 32,564
Recognized Expert Moderator MVP
Thanks Twinny. That makes the concept clearer.
Thanks very much for your help and also to NeoPa.
I have tried your correction and I'm now getting run-time error 3075
syntax error (missing operator) in query expression 'ID=(the variable)'.
I think the problem now is, as you suggested, the that the combo boxs Primary Key is not the bound column, as I can't see any values if I try to view all columns in the combo box.
The the after event code for the combo box is: - Private Sub cboPackageNumber_AfterUpdate()
-
Dim strSql As String
-
strSql = "SELECT o.Activity" & vbCrLf & _
-
"FROM tblActivity AS o" & vbCrLf & _
-
"WHERE o.PackageID = '" & cboPackageNumber.Value & "'" & vbCrLf & _
-
"ORDER BY o.PackageID;"
-
Debug.Print strSql
-
cboActivity.RowSource = strSql
-
End Sub
Thanks again in advance.
twinnyfo 3,653
Recognized Expert Moderator Specialist
Your SQL should be - SELECT o.PackageID, o.Activity .....
You also need to make sure the combo box is formatted for two columns, with the first column being bound.
Hope this hepps.
Thanks so much for your help! That's what I couldn't figure out.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: tshad |
last post by:
I am trying to set up a class to handle my database accesses.
I can't seem to figure out how to get the return value from my dataReader
from these routines (most of which I got elsewhere). They do work pretty
well, except for the change I made to get the return value.
For example, I have the following:...
|
by: marcmc |
last post by:
Is it in any way possible to have a sProc called and executed within
SQLServer return its return value to an open .Net Vb application?
As a programmer I beleive this can be done and if I wreck my head enough I
will find a way. I have toyed with the ideas of xml, SQLServer events but
have found nothing so far.
As this is the final stage of...
|
by: annbb |
last post by:
I have a piece of code which resets all the control on a form ..but if
I also put an option group on the form and the relevant code in the
routine to reset it I get an error message saying that you cant assign
a value to this object when the code reaches the line for the checkbox.
The code works perfectly if EITHER option group or checkbox...
|
by: lovecreatesbeauty |
last post by:
Hello experts,
Is the following code snippet legal? If it is, how can exit() do the
keyword return a favor and give a return value to the main function?
Can a function call (or only this exit(n)) statement provide both
function call and return features of the C programming language?
/* headers omitted */
int main (void)
|
by: Tim Roberts |
last post by:
I've been doing COM a long time, but I've just come across a behavior
with late binding that surprises me. VB and VBS are not my normal
milieux, so I'm hoping someone can point me to a document that
describes this.
Here's the setup. We have a COM server, written in Python. For
completeness, here is the script:
----- testserver.py...
| |
by: philip |
last post by:
hello, i am new to asp.net and sql server, and i have 3 questions for
asking:
1. i am writing a store procedure of login validation for my asp.net
application and wondering what the different between RETURN and SELECT
is.
if exists(select * from users where username = @username and password =
@password)
BEGIN
|
by: Marty James |
last post by:
Howdy,
I was reflecting recently on malloc.
Obviously, for tiny allocations like 20 bytes to strcpy a filename or
something, there's no point putting in a check on the return value of
malloc.
OTOH, if you're allocating a gigabyte for a large array, this might
fail, so you should definitely check for a NULL return.
|
by: Tinkertim |
last post by:
Hi,
I have often wondered if casting the return value of malloc() (or
friends) actually helps anything, recent threads here suggest that it
does not .. so I hope to find out.
For instance :
char *tmp = NULL;
|
by: thierry savard |
last post by:
I want the 2 compute column to show only 4 decimal, but I cant find a way to affect the return value of 'em.
I wrote down this command "compute avg(x)" because I need the average to be in a seperate table.
When you use compute avg(x) here x is cast (price as decimal(10,4)) because I need the price to show up in the main table, and I need it...
|
by: Rheigny |
last post by:
I dont know why I cant pass the value of AccountType (from TblAccount) to Me.txtWAccounType(textbox from WithdrawView)
pls help me.. here's my code
If IsNull(DLookup("", "TblAccount", "AccountId = '" & txtWAccountId & "'")) Then
MsgBox "Account Number Doesn't Exist"
Else
Me.txtWAccounType.Value = DLookup("", "TblAccount", "AccountId...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |