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

DLookup

77
Hi

i am having little trouble with my events code in Access..

I am using the following code to refer to the Availablilty field in the Add_Video table,

Private Sub Combo33_BeforeUpdate(Cancel As Integer)
If [Forms]![Add_Video]![Availability] = False Then
MsgBox "Video not available"

Else
End If

but as i run it i get the following msg..

"ms access cant find the form add video referred to in a macro expression or visual basic code
Mar 15 '07 #1
24 2834
missinglinq
3,532 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. If [Forms]![Add_Video]![Availability] = False
refers to a control on the form Add_Video, not ot a field in a table named Add_Video. Do you, in fact, have a form named Add_Video?

If you have a control on your form named Availability try

Expand|Select|Wrap|Line Numbers
  1.  Private Sub Combo33_BeforeUpdate(Cancel As Integer)
  2.   If Me.Availability] = False Then
  3.      MsgBox "Video not available"
  4.   End If
  5.  
Mar 15 '07 #2
Mubs
77
thanks for reply

i tried ur code but gor following msg..

syntax error..

my database is about a video rentals store..

i have a form called rentals, and in that when a customer chooses a video, the video might not be available, this info is in the video table under the field availability.. so what i am trying to do is create an event which will tell the user that a particular video is not available when they choose to rent a video..
Mar 15 '07 #3
missinglinq
3,532 Expert 2GB
Sorry, I accidentally left a bracket in when replacing your code with mine; that's what is throwing the error:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo33_BeforeUpdate(Cancel As Integer)
  2. If Me.Availability] = False Then
  3.   MsgBox "Video not available"
  4. End If
should be:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo33_BeforeUpdate(Cancel As Integer)
  2.  If Me.Availability = False Then
  3.   MsgBox "Video not available"
  4.  End If
Mar 15 '07 #4
Mubs
77
it is still incorrect
Mar 15 '07 #5
Rabbit
12,516 Expert Mod 8TB
Unless this is a snippet of code, you need End Sub at the end.
Mar 15 '07 #6
Mubs
77
i have also tried that and get the another error msg..

"compile error"..

what i need to know is how you referece a field in another table and check its data type, and if its false then i want msg showing that...

plz need asap help
Mar 16 '07 #7
Rabbit
12,516 Expert Mod 8TB
i have also tried that and get the another error msg..

"compile error"..

what i need to know is how you referece a field in another table and check its data type, and if its false then i want msg showing that...

plz need asap help
What? This sounds like a completely different question. If it is, it should be in a different thread.

The name of the field, Availability, sounds to me as if it's a numeric rather than boolean field. If numeric then you're looking for =0, if it's boolean then = False should work.
Mar 16 '07 #8
missinglinq
3,532 Expert 2GB
Yeah, Left End Sub of when copying and pasting!

Unless this is a snippet of code, you need End Sub at the end.
Mar 16 '07 #9
MMcCarthy
14,534 Expert Mod 8TB
i have a form called rentals, and in that when a customer chooses a video, the video might not be available, this info is in the video table under the field availability.. so what i am trying to do is create an event which will tell the user that a particular video is not available when they choose to rent a video..
It sounds like you're acutally looking for a DLookup. If the Video table is called Video and has a field called VideoName the code would be as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo33_BeforeUpdate(Cancel As Integer)
  2.    If DLookup("[Availability]", "Video", "[VideoName]=" & Me!Combo33) = False Then
  3.       MsgBox "Video not available"
  4.    End If
  5. End Sub
  6.  
Mary
Mar 16 '07 #10
Mubs
77
i have a table called Video and a field which i need to lookup is called availability.....
Mar 19 '07 #11
Rabbit
12,516 Expert Mod 8TB
i have a table called Video and a field which i need to lookup is called availability.....
This tells us nothing we don't already know. Look over the posts again and respond to the points brought up.
Mar 19 '07 #12
Mubs
77
none of the above codes are working.. i tried all of them...
Mar 19 '07 #13
Rabbit
12,516 Expert Mod 8TB
You say that you have a table called Video but your first post says Add_Video, which is it?

What is the name of video name or ID field? Is it a text or numeric field?
Mar 19 '07 #14
Mubs
77
the name of the table is "Video"... and the field is a yes/no field, the field i need to do a dlookup is for the "Availability" and thats in the "video" table..
Mar 20 '07 #15
MMcCarthy
14,534 Expert Mod 8TB
the name of the table is "Video"... and the field is a yes/no field, the field i need to do a dlookup is for the "Availability" and thats in the "video" table..
Yes but what is the name of the field that would correspond to the value in the combo box. That is where I am using VideoName in the below code
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo33_BeforeUpdate(Cancel As Integer)
  2.    If DLookup("[availability]", "Video", "[VideoName]=" & Me!Combo33) = False Then
  3.       MsgBox "Video not available"
  4.    End If
  5. End Sub
  6.  
Mar 20 '07 #16
Rabbit
12,516 Expert Mod 8TB
I didn't ask about the Availability field. What is the the field that uniquely identifies a video? Is that text or numeric? What is it called?
Mar 20 '07 #17
Mubs
77
its called video ID and its a text field
Mar 21 '07 #18
MMcCarthy
14,534 Expert Mod 8TB
So try this code ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo33_BeforeUpdate(Cancel As Integer)
  2.    If DLookup("[availability]", "Video", "[Video ID]=" & Me!Combo33) = False Then
  3.       MsgBox "Video not available"
  4.    End If
  5. End Sub
  6.  
Mar 21 '07 #19
Mubs
77
So try this code ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo33_BeforeUpdate(Cancel As Integer)
  2.    If DLookup("[availability]", "Video", "[Video ID]=" & Me!Combo33) = False Then
  3.       MsgBox "Video not available"
  4.    End If
  5. End Sub
  6.  
i get the msg " you cancelled the previous operation"
Mar 22 '07 #20
MMcCarthy
14,534 Expert Mod 8TB
i get the msg " you cancelled the previous operation"
What is the datatype of the Availability field?
Mar 22 '07 #21
Mubs
77
What is the datatype of the Availability field?

it is a yes/no data type
Mar 22 '07 #22
Denburt
1,356 Expert 1GB
Mind if I...
According to post #18
its called video ID and its a text field
if this is correct and your comboBox is bound to a text field and all the other info you provided is accurate then this should do it.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo33_BeforeUpdate(Cancel As Integer)
  2.    If DLookup("[availability]", "Video", "[Video ID]='" & Me!Combo33 & "'") = False Then
  3.       MsgBox "Video not available"
  4.    End If
  5. End Sub
  6.  
Mar 23 '07 #23
MMcCarthy
14,534 Expert Mod 8TB
Mind if I...
According to post #18


if this is correct and your comboBox is bound to a text field and all the other info you provided is accurate then this should do it.
Good catch.

Don't know how I missed that :rolleyes:
Mar 23 '07 #24
Denburt
1,356 Expert 1GB
Thanks np :)
Mar 23 '07 #25

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

Similar topics

1
by: KLAU | last post by:
I have a field that retrieves information from an expression in a query. I have used a DLookup function to get the calculated field from the query. However, the relationship is 1-to-many so one...
6
by: JLM | last post by:
What am I missing here? I have a form where I enter a "Class Code". This value corresponds to what sits in table "class code descriptions" along with the "title" of each "class code." Key...
5
by: Kalvin Schroder | last post by:
I am fairly new to Access, and am trying to put together an invoice form. The main form in called InvoiceDetailFm. Source is the table InvoiceDetail and has invoice number, saleman, and CustID as...
4
by: MLH | last post by:
I have tried using DLookUp in this manner... If DLookUp("","tblClients","='2021234567'") Then MsgBox "Found it!" End If I am wondering if that is a misuse of the DLookUp command? Type...
2
by: ctyrrell | last post by:
I have read with interest the many discussions of the 3048 Error: Cannot open any more databases. I understand how the number of open Table ID's causes the problem. My question has to do with the...
8
by: Christine Henderson | last post by:
I have a problem using the above function in the following simplified circumstance: In the lookup table called "Klms Travelled" I have 3 fields, eg: Receiver Name Receiver Suburb ...
11
by: MLH | last post by:
DLookup("", "tblPreliminaryVINs", "=Forms!frmVINODO!SerialNum") is giving me a Type Mismatch error. That's confusing to me and I don't know how to circumvent it. The field in...
2
by: Don | last post by:
Can someone help me fix my DLookup problem. I'm far from proficiency with Access. I've been creating databases for several years for work with the help of many of you and trial and error. I have...
9
by: | last post by:
In my database I have a 'control table' in which basic info is stored about the application, for instance the application's path and the name of the company that is using it. In all of the...
15
by: rleepac | last post by:
This is a little complicated but I'll do my best to explain. In my db I have a table called L_AgeCorrection which has the following fields: Age, Sex, Frequency, AgeValue This is a table used to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.