Check if data already exists in database.

  • Thread starter Stefan van der Hooft
  • Start date
S

Stefan van der Hooft

Hi,

Wonder if someone can help me please.

I’ve a form (F_OE_Ideas_FillIn) with a couple fields where users can put
their data in. After they put their data in, I’ve a submit button witch
select all the data from the fields on this specific form and put it in a
database table (T_OE_Ideas).

What I want…
Is a check if the data is already in the database,
1) if so: ask the user conform this operation and then continue or stop the
action.
2) if not:then put the data into the table (T_OE_Ideas) without confirmation.

Is this possible?

Kind regards, Stefan van der Hooft.
 
A

Alex Dybenko

Hi,
you can create a query, based on T_OE_Ideas, where all fields has criteria
to corresponding fields on F_OE_Ideas_FillIn
then you run with query and check if it returns any records:
if DCount("*","MyQuery") > 0 then
'confirmation
else
'just save
end if

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
 
S

Stefan van der Hooft

Hi! It works but no I’ve another problem…

The property of the field is Date, but it’s shown as feb-2007 (mmm-yyyy) on
my form. What I want is that the code checks this format, example:
When a user entered on 1-2-2007 some data and a other user want to enter
some data on 10-2-2007 the system must not allowed this because it has the
same month.

Is this also possible?

Kind regards, Stefan van der Hooft.

Ps. this is the code behind the button
--------------------------------------------------------------------------------------
Private Sub Command47_Click()
Dim VeldDatum As String
DateFromField = Field_Date.Value

If [Fld_Date] = Q_OE_Ideas_LastDate Then
MsgBox "De maand " + DateFromField + " staat al in de database"
Else
MsgBox "just save"
End If
End Su
--------------------------------------------------------------------------------------
 
A

Alex Dybenko

hi,
if both are stored/entered as dates - then you can compare following way:

If format([Fld_Date],"mm-yy") = format(Q_OE_Ideas_LastDate,"mm-yy") Then


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

Stefan van der Hooft said:
Hi! It works but no I’ve another problem…

The property of the field is Date, but it’s shown as feb-2007 (mmm-yyyy)
on
my form. What I want is that the code checks this format, example:
When a user entered on 1-2-2007 some data and a other user want to enter
some data on 10-2-2007 the system must not allowed this because it has the
same month.

Is this also possible?

Kind regards, Stefan van der Hooft.

Ps. this is the code behind the button:
--------------------------------------------------------------------------------------
Private Sub Command47_Click()
Dim VeldDatum As String
DateFromField = Field_Date.Value

If [Fld_Date] = Q_OE_Ideas_LastDate Then
MsgBox "De maand " + DateFromField + " staat al in de database"
Else
MsgBox "just save"
End If
End Sub
--------------------------------------------------------------------------------------

Alex Dybenko said:
Hi,
you can create a query, based on T_OE_Ideas, where all fields has
criteria
to corresponding fields on F_OE_Ideas_FillIn
then you run with query and check if it returns any records:
if DCount("*","MyQuery") > 0 then
'confirmation
else
'just save
end if

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Stefan van der Hooft" <[email protected]>
wrote
in message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top