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.
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.
6 1439 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,556
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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....
|
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 :
...
|
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...
|
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",...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: 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...
|
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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |