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

inputbox and dlookup issues

dear respected Gurus,

i would like to know what is wrong with my codes, i wanted to put
PolicyNo(say any string value, which is PK in table)...how to do? as i
make one inputbox it asked the value, but says "you cancelled the
previous opertion"

Private Sub btnAdd_Click()
Dim msgTitle As String
Dim strInput As String
Dim lblInput As String
Dim varChk As Boolean

msgTitle = "New Policy No."
lblInput = "Enter new Policy No."
strInput = InputBox(lblInput, msgTitle)

varChk = DLookup(strInput, "[BURGLARY2000]", "[POLICYNO]=" & strInput)

If varChk = True Then
MsgBox "Policy Issued"
Else
MsgBox "Policy not Issued"
End If

regards,
your studnet
Shahzad
End Sub
Nov 13 '05 #1
3 2382
The problem is that you're using strInput twice in your DLookup statement:
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"MUHAMAMD SALIM SHAHZAD" <ms******@yahoo.ca> wrote in message
news:5a**************************@posting.google.c om...
dear respected Gurus,

i would like to know what is wrong with my codes, i wanted to put
PolicyNo(say any string value, which is PK in table)...how to do? as i
make one inputbox it asked the value, but says "you cancelled the
previous opertion"

Private Sub btnAdd_Click()
Dim msgTitle As String
Dim strInput As String
Dim lblInput As String
Dim varChk As Boolean

msgTitle = "New Policy No."
lblInput = "Enter new Policy No."
strInput = InputBox(lblInput, msgTitle)

varChk = DLookup(strInput, "[BURGLARY2000]", "[POLICYNO]=" & strInput)

If varChk = True Then
MsgBox "Policy Issued"
Else
MsgBox "Policy not Issued"
End If

regards,
your studnet
Shahzad
End Sub

Nov 13 '05 #2
Sorry, somehow that got sent before I was finished typing.

The first argument in DLookup is supposed to be a field name, not a value.

The other problem is that DLookup isn't going to return a Boolean value
(unless that's the data type of the field you're trying to return)

Try the following:

Private Sub btnAdd_Click()
Dim msgTitle As String
Dim strInput As String
Dim lblInput As String
Dim lngCount As Long

msgTitle = "New Policy No."
lblInput = "Enter new Policy No."
strInput = InputBox(lblInput, msgTitle)

lngCount = DCount("*", "[BURGLARY2000]", "[POLICYNO]=" & strInput)

If lngCount > 0 Then
MsgBox "Policy Issued"
Else
MsgBox "Policy not Issued"
End If
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:XW******************@news04.bloor.is.net.cabl e.rogers.com...
The problem is that you're using strInput twice in your DLookup statement:
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"MUHAMAMD SALIM SHAHZAD" <ms******@yahoo.ca> wrote in message
news:5a**************************@posting.google.c om...
dear respected Gurus,

Nov 13 '05 #3
ms******@yahoo.ca (MUHAMAMD SALIM SHAHZAD) wrote in
news:5a**************************@posting.google.c om:
dear respected Gurus,

i would like to know what is wrong with my codes, i wanted to
varChk = DLookup(strInput, "[BURGLARY2000]", "[POLICYNO]=" &
strInput)


Dlookup doesn't work the way you are trying to use it.

Try
varchk = not isnull(dlookup("[policyno]","[burglary_2000]",
"[Policyno]= '" & strinput " "'"))
Bob Quintal
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: MUHAMAMD SALIM SHAHZAD | last post by:
dear sir, i would like to get your assitance about the above issues, can't find any better slutions or codes - table name: MOTOR2000 - field name1: POLICYNO - field name2: ExPolicyNo i...
3
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...
1
by: Hans Kamp | last post by:
How do I use InputBox? private void addButton_Click(object sender, System.EventArgs e) { string newName; newName = InputBox("t1", "t2", "t3"); namesListBox.Items.Add(newName); }
1
by: | last post by:
When trying to use the InputBox function I get the error "InputBox is a namespace and therefore is not a valid expression". Can anyone tell me what the problem is? Thanks.
1
by: Parasyke | last post by:
I have a form (I won't bore you with the details of the necessity of this, but), I need to have a textbox that uses DLookup to get a value from a table with both being keyed to a common field...
6
by: ApexData | last post by:
When I use Dlookup. I am only able to return a single value and therefore cannot seem to assign a single records (3-field values) to (3-Variables). I noticed that I can get the 3-field values, but...
3
by: Birky | last post by:
Can someone please help me with my syntax below? I am trying to enable an object on a form for specific users only and in doing so I am trying to use the DLookUp function to try and keep it sweet and...
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...
2
by: RoadrunnerII | last post by:
Hi All I am new to this forum and still learning MS Access. Hoping this is the right place to ask If not please let me know! Looking for some help with the SQL statements in Access 2003 with the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.