473,401 Members | 2,068 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,401 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 2841
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
isladogs
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 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.