Hello
I haven't done much Access work for a while and so am a bit rusty. Having a problem and hope someone can help.
I have a look-up (combo) box on a form displaying course details. The form shows courses for a specific agency - the agency is filtered as that shown on a previous form.
When using the look-up box, if a course is selected that doesn't exist for the specific agency then nothing happens - I'd really like to display a message box that says "no course available" or something - but can't figure out where to put the message box code or how to call it
so far I have
Private Sub Combo23_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[course name] = '" & Me![Combo23] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
The closest I've got to making anything happen was by putting
If rstRecordSet.EOF = False Then MsgBox "No course of this name listed for this agency" before the End Sub - but I get a run-time error which says "run-time error 424 object required"
totally out of my depth - any help appreciated
thanks
Shona
15 1508 Stwange 126
Recognized Expert New Member
Try this, it should work but I haven't tested it: -
Private Sub Combo23_AfterUpdate()
-
IF DCount("*","YourTableName",[course name] = '" & Me![Combo23] & "') <> 0 then
-
' Find the record that matches the control.
-
Dim rs As Object
-
Set rs = Me.Recordset.Clone
-
rs.FindFirst "[course name] = '" & Me![Combo23] & "'"
-
Else
-
msgbox "No course of this name listed for this agency", vbcritical, "Course not found."
-
End If
-
End Sub
-
Hope this helps.
I replaced "your table name" with "courses" - it didn't like the second " so I took it off - but afraid it still doesn't call the message box
the code I have is:
Private Sub Combo23_AfterUpdate()
If DCount("*", "courses,[course name] = '" & Me![Combo23] & "'") <> 0 Then
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[course name] = '" & Me![Combo23] & "'"
Else
MsgBox "No course of this name listed for this agency", vbCritical, "Course not found."
End If
End Sub
and this returns a run-time error: 3078 - the Microsoft Jet database engine cannot find the input table or query 'courses,[course name] = "name of the course I was looking for". Make sure it exists and that its name is spelled correctly.
many thanks
Shona
Stwange 126
Recognized Expert New Member
Try replacing it with this instead: -
IF DCount("*","courses",[course name] = '" & Me![Combo23] & "'")
-
(I missed out a " sorry, it should have had one added, not deleted)
thanks again - am now getting the line that starts "If Dcount ..." coming up in red and at the part [course name] = ' " the ' is highlighted and it says compile error expected expression.
sorry to be a pest
best wishes
Shona
Stwange 126
Recognized Expert New Member
sorry to be a pest
Not at all, if anything it's my fault for giving you bad code...twice. I missed out a " again! try this one: - If DCount("*", "courses,"[course name] = '" & Me![Combo23] & "'") <> 0 Then
-
Good luck :)
Fraid not - the line is red and I get compile error - syntax error when I access the combo box
thanks again
Shona
Stwange 126
Recognized Expert New Member
Fraid not - the line is red and I get compile error - syntax error when I access the combo box
thanks again
Shona
Please can you paste/rewrite the syntax error? This is getting embarrassing :)
That's all it says:
I click on a course in the combo box that doesn't exist for the selected agency - the screen flicks to the Visual Basic screen with the DCount row highlighted and a grey pop-up box that says :
Compile error:
Syntax error
with the yellow triangle and ! sign but no other detail
I'm really sorry
Shona
Stwange 126
Recognized Expert New Member
That's all it says:
I click on a course in the combo box that doesn't exist for the selected agency - the screen flicks to the Visual Basic screen with the DCount row highlighted and a grey pop-up box that says :
Compile error:
Syntax error
with the yellow triangle and ! sign but no other detail
I'm really sorry
Shona
I think I've seen the problem, and I swear I'm going to get it right this time:
If DCount("*", "courses","[course name] = '" & Me![Combo23] & "'") <> 0 Then
Let me know, and good luck :)
please don't hate me but -
compile error: expected: =
the <> is highlighted
IGNORE THAT - missed the If - trying again
well - the good news is that there isn't an error message but I'm afraid the message box doesn't appear
maybe it's just not meant to be
Have to dash off for the school run now but many thanks for all your patience and help
Shona
Stwange 126
Recognized Expert New Member
well - the good news is that there isn't an error message but I'm afraid the message box doesn't appear
maybe it's just not meant to be
Have to dash off for the school run now but many thanks for all your patience and help
Shona
No problem. I'm leaving work now anyway, I'll see if I get chance to have another look either tonight or tomorrow. If anyone else can suggest a problem in my coding, it would be helpful :)
Good morning - took my old Access VB book home for a bit of light reading and came up with
Private Sub Combo23_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[course name] = '" & Me![Combo23] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
If [course name].Value <> Me![Combo23] Then
MsgBox "No course of this name listed for this agency"
End If
End Sub
and it seems to work - hurrah!!
Many, many thanks for your help yesterday
Shona
Stwange 126
Recognized Expert New Member
Many, many thanks for your help yesterday
Shona
No problem, and sorry I wasn't successful!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: CoreyWhite |
last post by:
The future of computer architecture will use lookup tables. Currently
computer processor speed outweighs the benefits of using computer
memory for lookup tables, except in some cases. As computer...
|
by: James E |
last post by:
I have a question about best practices of how to deal with lookup data from
my C# apps. On a couple of occasions I have come across a problem where I
have to automate inserting a record into a...
|
by: my-wings |
last post by:
I've been reading about how evil Lookup fields in tables are, but I've got
to be missing something really basic. I know this subject has been covered
before, because I've just spent an hour or two...
|
by: Tripp Knightly |
last post by:
I have a lookup table from which I want to categorize various bands of
customer net income. Some of the income is positive, some is
negative. The bands vary in size (ie, <500, -200 to 0, 100 to...
|
by: google |
last post by:
I have a database with four table. In one of the tables, I use about
five lookup fields to get populate their dropdown list. I have read
that lookup fields are really bad and may cause problems...
|
by: James |
last post by:
I am used to VB6 but need to develop something in .Net.
I need to create several bound combo-boxes which will use lookup tables to
get their values.
I created a form using the dataform wizard....
|
by: jon f kaminsky |
last post by:
Hi-
I've seen this problem discussed a jillion times but I cannot seem to
implement any advice that makes it work. I am porting a large project from
VB6 to .NET. The issue is using the combo box...
|
by: |
last post by:
I have what's probably a simple page lifecycle question related to
dynamically evaluating values that are placed by a repeater and dynmically
placing user controls that use those values.
I'm...
|
by: paulquinlan100 |
last post by:
Hi
Im having problems getting a column in one of my tables to display the
lookup values correctly.
The database is split, in the backend the rowsource for this
particular field is set to a...
|
by: Juha Nieminen |
last post by:
The so-called koenig lookup allows doing odd things like this:
#include <algorithm>
#include <string>
int main()
{
std::string table;
sort(table, table+10);
}
|
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: 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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |