duplication record

G

Guest

Hi,
This is my tables:

Registration(RegistrationID,CustomerID,RoomID,StartDate,EndDate)
Room(RoomID,RoomNo,BlockID,TypeID,PriceID,Register,Notes)

The form will saved all the record into table Registration.
How can I prevent duplication of the record in my form?
I want the form to validate if the same Registration.CustomerID with
Room.Register=True, the record can't be saved and message will be appeared.
I appreciate any guidance, thank you.
 
G

Guest

First create a query that link both tables, so it will return the Register
for each customer

On the before update event of the customer text box add the code that check
for duplicates in query above

If DCount("*","[QueryName]","CustomerID = " & Me.[CustomerID] & " And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

If the CustomerId is a string type field you need to change the criteria
adding single quote

If DCount("*","[QueryName]","CustomerID = '" & Me.[CustomerID] & "' And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If
 
G

Guest

Thanks for the reply. I've never done any query before, so I just select all
the fields from both table Registration and Room. Is it correct?

After that, I put the code at before update but it is not working. For your
information, to validate another fields at the same form is not null, I've
put all the code at on click event. Is it because of the on click event, the
before update event is not working or I make any other mistakes?
The txtCustomerID at the form also is been passed from another form using
OpenArgs, I just inform if it have any connection to the 'not working' matter.

Sorry for those questions, I'm a newbie and the questions asked could be
ridiculous and thank you again.

Ofer Cohen said:
First create a query that link both tables, so it will return the Register
for each customer

On the before update event of the customer text box add the code that check
for duplicates in query above

If DCount("*","[QueryName]","CustomerID = " & Me.[CustomerID] & " And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

If the CustomerId is a string type field you need to change the criteria
adding single quote

If DCount("*","[QueryName]","CustomerID = '" & Me.[CustomerID] & "' And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

--
Good Luck
BS"D


yanz said:
Hi,
This is my tables:

Registration(RegistrationID,CustomerID,RoomID,StartDate,EndDate)
Room(RoomID,RoomNo,BlockID,TypeID,PriceID,Register,Notes)

The form will saved all the record into table Registration.
How can I prevent duplication of the record in my form?
I want the form to validate if the same Registration.CustomerID with
Room.Register=True, the record can't be saved and message will be appeared.
I appreciate any guidance, thank you.
 
G

Guest

Thanks for the reply. I've never done any query before, so I just select all
the fields from both table Registration and Room. Is it correct?

In addition, you need to link both tables using the field that ia common in
both of them.

Can you post the SQL (query) you have now and the code you used in the
BeforeUpdate event?

When you say it doesn't work do you mean you get an error message or it
doesnt track duplicates?

--
Good Luck
BS"D


yanz said:
Thanks for the reply. I've never done any query before, so I just select all
the fields from both table Registration and Room. Is it correct?

After that, I put the code at before update but it is not working. For your
information, to validate another fields at the same form is not null, I've
put all the code at on click event. Is it because of the on click event, the
before update event is not working or I make any other mistakes?
The txtCustomerID at the form also is been passed from another form using
OpenArgs, I just inform if it have any connection to the 'not working' matter.

Sorry for those questions, I'm a newbie and the questions asked could be
ridiculous and thank you again.

Ofer Cohen said:
First create a query that link both tables, so it will return the Register
for each customer

On the before update event of the customer text box add the code that check
for duplicates in query above

If DCount("*","[QueryName]","CustomerID = " & Me.[CustomerID] & " And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

If the CustomerId is a string type field you need to change the criteria
adding single quote

If DCount("*","[QueryName]","CustomerID = '" & Me.[CustomerID] & "' And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

--
Good Luck
BS"D


yanz said:
Hi,
This is my tables:

Registration(RegistrationID,CustomerID,RoomID,StartDate,EndDate)
Room(RoomID,RoomNo,BlockID,TypeID,PriceID,Register,Notes)

The form will saved all the record into table Registration.
How can I prevent duplication of the record in my form?
I want the form to validate if the same Registration.CustomerID with
Room.Register=True, the record can't be saved and message will be appeared.
I appreciate any guidance, thank you.
 
G

Guest

This is my query,ValidateRegistration:

SELECT Registration.RegistrationID, Registration.CustomerID,
Registration.RoomID AS Registration_RoomID, Registration.StartDate,
Registration.EndDate, Room.RoomID AS Room_RoomID, Room.RoomNo, Room.BlockID,
Room.TypeID, Room.PriceID, Room.Register, Room.Notes
FROM Room INNER JOIN Registration ON Room.RoomID = Registration.RoomID;

And this is the code at txtCustomerID:

Private Sub txtCustomerID_BeforeUpdate(Cancel As Integer)
If DCount("*", "[ValidateRegistration]", "CustomerID = '" &
Me.[txtCustomerID] & "' And Register = True") > 0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If
End Sub

It is not working mean it does not track the duplication. Thanks again.

Ofer Cohen said:
Thanks for the reply. I've never done any query before, so I just select all
the fields from both table Registration and Room. Is it correct?

In addition, you need to link both tables using the field that ia common in
both of them.

Can you post the SQL (query) you have now and the code you used in the
BeforeUpdate event?

When you say it doesn't work do you mean you get an error message or it
doesnt track duplicates?

--
Good Luck
BS"D


yanz said:
Thanks for the reply. I've never done any query before, so I just select all
the fields from both table Registration and Room. Is it correct?

After that, I put the code at before update but it is not working. For your
information, to validate another fields at the same form is not null, I've
put all the code at on click event. Is it because of the on click event, the
before update event is not working or I make any other mistakes?
The txtCustomerID at the form also is been passed from another form using
OpenArgs, I just inform if it have any connection to the 'not working' matter.

Sorry for those questions, I'm a newbie and the questions asked could be
ridiculous and thank you again.

Ofer Cohen said:
First create a query that link both tables, so it will return the Register
for each customer

On the before update event of the customer text box add the code that check
for duplicates in query above

If DCount("*","[QueryName]","CustomerID = " & Me.[CustomerID] & " And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

If the CustomerId is a string type field you need to change the criteria
adding single quote

If DCount("*","[QueryName]","CustomerID = '" & Me.[CustomerID] & "' And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

--
Good Luck
BS"D


:

Hi,
This is my tables:

Registration(RegistrationID,CustomerID,RoomID,StartDate,EndDate)
Room(RoomID,RoomNo,BlockID,TypeID,PriceID,Register,Notes)

The form will saved all the record into table Registration.
How can I prevent duplication of the record in my form?
I want the form to validate if the same Registration.CustomerID with
Room.Register=True, the record can't be saved and message will be appeared.
I appreciate any guidance, thank you.
 
G

Guest

It look OK,

It's hard for me to check without seeing the data, if you would like send
the MDB to
chamudim <@> hotmail <.> com

I can check the code using your data.
If you decide to do that please zip the mdb, either wise hotmail will reject
it.



--
Good Luck
BS"D


yanz said:
This is my query,ValidateRegistration:

SELECT Registration.RegistrationID, Registration.CustomerID,
Registration.RoomID AS Registration_RoomID, Registration.StartDate,
Registration.EndDate, Room.RoomID AS Room_RoomID, Room.RoomNo, Room.BlockID,
Room.TypeID, Room.PriceID, Room.Register, Room.Notes
FROM Room INNER JOIN Registration ON Room.RoomID = Registration.RoomID;

And this is the code at txtCustomerID:

Private Sub txtCustomerID_BeforeUpdate(Cancel As Integer)
If DCount("*", "[ValidateRegistration]", "CustomerID = '" &
Me.[txtCustomerID] & "' And Register = True") > 0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If
End Sub

It is not working mean it does not track the duplication. Thanks again.

Ofer Cohen said:
Thanks for the reply. I've never done any query before, so I just select all
the fields from both table Registration and Room. Is it correct?

In addition, you need to link both tables using the field that ia common in
both of them.

Can you post the SQL (query) you have now and the code you used in the
BeforeUpdate event?

When you say it doesn't work do you mean you get an error message or it
doesnt track duplicates?

--
Good Luck
BS"D


yanz said:
Thanks for the reply. I've never done any query before, so I just select all
the fields from both table Registration and Room. Is it correct?

After that, I put the code at before update but it is not working. For your
information, to validate another fields at the same form is not null, I've
put all the code at on click event. Is it because of the on click event, the
before update event is not working or I make any other mistakes?
The txtCustomerID at the form also is been passed from another form using
OpenArgs, I just inform if it have any connection to the 'not working' matter.

Sorry for those questions, I'm a newbie and the questions asked could be
ridiculous and thank you again.

:

First create a query that link both tables, so it will return the Register
for each customer

On the before update event of the customer text box add the code that check
for duplicates in query above

If DCount("*","[QueryName]","CustomerID = " & Me.[CustomerID] & " And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

If the CustomerId is a string type field you need to change the criteria
adding single quote

If DCount("*","[QueryName]","CustomerID = '" & Me.[CustomerID] & "' And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

--
Good Luck
BS"D


:

Hi,
This is my tables:

Registration(RegistrationID,CustomerID,RoomID,StartDate,EndDate)
Room(RoomID,RoomNo,BlockID,TypeID,PriceID,Register,Notes)

The form will saved all the record into table Registration.
How can I prevent duplication of the record in my form?
I want the form to validate if the same Registration.CustomerID with
Room.Register=True, the record can't be saved and message will be appeared.
I appreciate any guidance, thank you.
 
G

Guest

Thanks, I'll send the mdb to you right away. Thanks again.

Ofer Cohen said:
It look OK,

It's hard for me to check without seeing the data, if you would like send
the MDB to
chamudim <@> hotmail <.> com

I can check the code using your data.
If you decide to do that please zip the mdb, either wise hotmail will reject
it.



--
Good Luck
BS"D


yanz said:
This is my query,ValidateRegistration:

SELECT Registration.RegistrationID, Registration.CustomerID,
Registration.RoomID AS Registration_RoomID, Registration.StartDate,
Registration.EndDate, Room.RoomID AS Room_RoomID, Room.RoomNo, Room.BlockID,
Room.TypeID, Room.PriceID, Room.Register, Room.Notes
FROM Room INNER JOIN Registration ON Room.RoomID = Registration.RoomID;

And this is the code at txtCustomerID:

Private Sub txtCustomerID_BeforeUpdate(Cancel As Integer)
If DCount("*", "[ValidateRegistration]", "CustomerID = '" &
Me.[txtCustomerID] & "' And Register = True") > 0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If
End Sub

It is not working mean it does not track the duplication. Thanks again.

Ofer Cohen said:
Thanks for the reply. I've never done any query before, so I just select all
the fields from both table Registration and Room. Is it correct?

In addition, you need to link both tables using the field that ia common in
both of them.

Can you post the SQL (query) you have now and the code you used in the
BeforeUpdate event?

When you say it doesn't work do you mean you get an error message or it
doesnt track duplicates?

--
Good Luck
BS"D


:

Thanks for the reply. I've never done any query before, so I just select all
the fields from both table Registration and Room. Is it correct?

After that, I put the code at before update but it is not working. For your
information, to validate another fields at the same form is not null, I've
put all the code at on click event. Is it because of the on click event, the
before update event is not working or I make any other mistakes?
The txtCustomerID at the form also is been passed from another form using
OpenArgs, I just inform if it have any connection to the 'not working' matter.

Sorry for those questions, I'm a newbie and the questions asked could be
ridiculous and thank you again.

:

First create a query that link both tables, so it will return the Register
for each customer

On the before update event of the customer text box add the code that check
for duplicates in query above

If DCount("*","[QueryName]","CustomerID = " & Me.[CustomerID] & " And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

If the CustomerId is a string type field you need to change the criteria
adding single quote

If DCount("*","[QueryName]","CustomerID = '" & Me.[CustomerID] & "' And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

--
Good Luck
BS"D


:

Hi,
This is my tables:

Registration(RegistrationID,CustomerID,RoomID,StartDate,EndDate)
Room(RoomID,RoomNo,BlockID,TypeID,PriceID,Register,Notes)

The form will saved all the record into table Registration.
How can I prevent duplication of the record in my form?
I want the form to validate if the same Registration.CustomerID with
Room.Register=True, the record can't be saved and message will be appeared.
I appreciate any guidance, thank you.
 
G

Guest

I tried the form, entering customer number 123456-89-1011 that have Register
= True, and the process stoped.

Mybe I'm missing somethng but I thought that waht you are asking for.

--
Good Luck
BS"D


yanz said:
Thanks, I'll send the mdb to you right away. Thanks again.

Ofer Cohen said:
It look OK,

It's hard for me to check without seeing the data, if you would like send
the MDB to
chamudim <@> hotmail <.> com

I can check the code using your data.
If you decide to do that please zip the mdb, either wise hotmail will reject
it.



--
Good Luck
BS"D


yanz said:
This is my query,ValidateRegistration:

SELECT Registration.RegistrationID, Registration.CustomerID,
Registration.RoomID AS Registration_RoomID, Registration.StartDate,
Registration.EndDate, Room.RoomID AS Room_RoomID, Room.RoomNo, Room.BlockID,
Room.TypeID, Room.PriceID, Room.Register, Room.Notes
FROM Room INNER JOIN Registration ON Room.RoomID = Registration.RoomID;

And this is the code at txtCustomerID:

Private Sub txtCustomerID_BeforeUpdate(Cancel As Integer)
If DCount("*", "[ValidateRegistration]", "CustomerID = '" &
Me.[txtCustomerID] & "' And Register = True") > 0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If
End Sub

It is not working mean it does not track the duplication. Thanks again.

:

Thanks for the reply. I've never done any query before, so I just select all
the fields from both table Registration and Room. Is it correct?

In addition, you need to link both tables using the field that ia common in
both of them.

Can you post the SQL (query) you have now and the code you used in the
BeforeUpdate event?

When you say it doesn't work do you mean you get an error message or it
doesnt track duplicates?

--
Good Luck
BS"D


:

Thanks for the reply. I've never done any query before, so I just select all
the fields from both table Registration and Room. Is it correct?

After that, I put the code at before update but it is not working. For your
information, to validate another fields at the same form is not null, I've
put all the code at on click event. Is it because of the on click event, the
before update event is not working or I make any other mistakes?
The txtCustomerID at the form also is been passed from another form using
OpenArgs, I just inform if it have any connection to the 'not working' matter.

Sorry for those questions, I'm a newbie and the questions asked could be
ridiculous and thank you again.

:

First create a query that link both tables, so it will return the Register
for each customer

On the before update event of the customer text box add the code that check
for duplicates in query above

If DCount("*","[QueryName]","CustomerID = " & Me.[CustomerID] & " And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

If the CustomerId is a string type field you need to change the criteria
adding single quote

If DCount("*","[QueryName]","CustomerID = '" & Me.[CustomerID] & "' And
Register = True") >0 Then
MsgBox "Room already selected"
Cancel = True 'stop the process
End If

--
Good Luck
BS"D


:

Hi,
This is my tables:

Registration(RegistrationID,CustomerID,RoomID,StartDate,EndDate)
Room(RoomID,RoomNo,BlockID,TypeID,PriceID,Register,Notes)

The form will saved all the record into table Registration.
How can I prevent duplication of the record in my form?
I want the form to validate if the same Registration.CustomerID with
Room.Register=True, the record can't be saved and message will be appeared.
I appreciate any guidance, thank you.
 

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