Hi,
firstly, here is my code: - Private Sub paragelia_BeforeUpdate(Cancel As Integer)
-
Dim varTemp As Variant
-
Dim varTemp1 As Variant
-
Dim sFilter As String
-
Dim inputtext As Long
-
Dim astrWhere As String
-
-
-
inputtext = InStr(1, Forms![frm_kataxorisi]![paragelia], "-")
-
-
sFilter = Left(Forms![frm_kataxorisi]![paragelia], inputtext - 1)
-
varTemp = DLookup("[ypiresia]", "tbl_kataxorisi", "[ypiresia] = Forms![frm_kataxorisi]![ypiresia]")
-
-
varTemp1 = DLookup("[paragelia]", "tbl_kataxorisi", "[paragelia] like 'sFilter'")
-
-
-
If varTemp = Forms![frm_kataxorisi]![ypiresia] And varTemp1 = Forms![frm_kataxorisi]![paragelia] Then
-
Me.Undo
-
MsgBox "Η Τιμή αυτή έχει ήδη καταχωρηθεί", vbOKOnly, "Προσοχή Διπλότυπη καταχώρηση"
-
Else
-
MsgBox ("hi")
-
End If
-
-
End Sub
I manage to take the value before (-) with sFilter(string), but i cannot put this in dlookup function to find only values, which will consist of sFilter value.
Thanks in advance!
For a LIKE you need to use a "*" or "%" as wildcharacter.
So for a match with "1052-a" you would need as LIKE string "1052%" so the code would look like: -
varTemp1 = DLookup("[paragelia]", "tbl_kataxorisi", "[paragelia] like '"& sFilter & "%'")
Nic;o)
9 2752
Change: - varTemp1 = DLookup("[paragelia]", "tbl_kataxorisi", "[paragelia] like 'sFilter'")
into - varTemp1 = DLookup("[paragelia]", "tbl_kataxorisi", "[paragelia] like '"& sFilter & "'")
Nic;o)
thanks for your answer.
Now, i dont face any problem but i cannot have that i want because if i put in field Forms![frm_kataxorisi]![paragelia] the value 1052-a, the string sFilter take the value =1052, but after that no value in vartemp1=null, and i dont why is happening.
If i dont use like function and just take the whole field everything is ok.
For a LIKE you need to use a "*" or "%" as wildcharacter.
So for a match with "1052-a" you would need as LIKE string "1052%" so the code would look like: -
varTemp1 = DLookup("[paragelia]", "tbl_kataxorisi", "[paragelia] like '"& sFilter & "%'")
Nic;o)
thanks again.
I try this, but nothing happening.
Lets say that when i write (1052/12-a or 1234-5 or 1052-f), i take as sFilter= 1052/12 or 1234 or 1052 and i want to search my table.[paragelia], so as to see if there is a value which will consist of these values.
In my table i have values 1052/12-a-b, 1052-b, 1234.
Can you place a breakpoint in the code (click in left ruler) and execute the code till the DLOOKUP.
Next type in the immediate window at the bottom: - ?"[paragelia] like '"& sFilter & "%'"
and report here the result.
Nic;o)
here is my report
[paragelia] like '1052%'
I understand my fault nico5038, after your propositions.
I had to change my .....If varTemp = Forms![frm_kataxorisi]![ypiresia] And varTemp1 = Forms![frm_kataxorisi]![paragelia] Then...... with..... If varTemp = Forms![frm_kataxorisi]![ypiresia] And varTemp1>0 Then....., so as my code says that there is a record which catch these criterias.
Thanks very match for your replies.
P.S. Do you know any way to have management system about my ms access db, i want to create manually login users with permissions and i id like to have a log files.
I personally use regularly the windows userid of the person logged in. You can get that using the environ() function like: - strUsername = environ("username")
Thus I'm sure only people allowed to use the system will be able to run my access application. Placing the allowed users within the company in an authorization table will limit the access to the intended users and you can log the users starting the application.
Nic;o)
thanks again.
Have a nice day!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Polar |
last post by:
I am having troubles finding the parse error in this script. I've been
checking for weeks. I am too new to the subject I guess.
I am trying to show a readord and them have a form at the bottom...
|
by: Maziar Aflatoun |
last post by:
Hi everyone,
I setup windows authentication on my webapplication. It's been working fine
for the past two years. But all of a sudden it gives me the following error
when I login using one of...
|
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...
|
by: Steve Richfield |
last post by:
My error handler works GREAT. However, VBA seems to have some
bugs/features that are causing it fits. The little snippet that I put
at the end of each routine looks like this:
Error_Handler:
If...
|
by: Uros |
last post by:
Hello!
I have problem with my function and I can find what's wrong.
WARNING: Error occurred while executing PL/pgSQL function fn_insert_entry_pending
WARNING: line 26 at SQL statement...
|
by: nzyui |
last post by:
Trying to lookup a field from a table called condition this is a separate
table not linked to anything: setup as shown
Code S M L
DG 1 2 3
RI 2 4 5
need...
|
by: access345 |
last post by:
I have created a form to lookup components in a table. The problem I am having is the table I have has multiple designations in the same field. Ex CR2,CR4,CR18
If I am looking up a field that has...
|
by: bagya |
last post by:
please help me out
the following is the small code i have
<html>
<head>
<script type="text/javascript">
function validate()
{
if (document.abc.region.value==0)
|
by: niteshkpatil |
last post by:
Hi,
I am compiling a C program on Hp-UX11.11 using the HP C compiler.
% cc test.c (say for example....)
I get the following message and the compilation is aborted.
% cc: panic 3011:
|
by: Paul Furman |
last post by:
How do I turn off MySQL error reporting? I set error_reporting(0); but
that doesn't seem to be working.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
| |