Data Keeps getting erased

G

Guest

This has been ongoing for the past 2 weeks and I'm tired of having to go into
the Table and Fixing it!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I have a form with an Unbound Combo Box. Every dam time I go and run a test
on 3 companies the data gets messed up. Once this database goes live WE
DON'T WANT TO HAVE THIS KEEP HAPPENING as the Users WILL NOT KNOW HOW TO FIX
IT!!!!!!!!!!!!!!!!!

I've have asked several times on this board on how to fix this and I haven't
gotten an answer yet that will fix the problem.

All the fields keeps getting overwritten including the IDnumber which is my
primary key.

This form is used for SEARCHING ONLY. It should NOT be Updating, deleting
or editing or doing anything but to SEARCH ONLY!!!!

Here is the code for the Form:

Option Compare Database

Private Sub Additional_Contacts_Click()
On Error GoTo Err_Additional_Contacts_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stWhere As String

stDocName = "sfrm_CTAContactsView"
stWhere = "[IDNumber] = '" & Me!Number_Text & "'"
DoCmd.OpenForm stDocName, acNormal, stLinkCriteria, stWhere

Exit_Additional_Contacts_Click:
Exit Sub

Err_Additional_Contacts_Click:
MsgBox Err.Description
Resume Exit_Additional_Contacts_Click

End Sub

Private Sub CTA_Notes_Click()
On Error GoTo Err_CTA_Notes_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stWhere As String

stDocName = "sfrm_CTANotesView"
stWhere = "[IDNumber] = '" & Me!Number_Text & "'"
DoCmd.OpenForm stDocName, acNormal, stLinkCriteria, stWhere

Exit_Additional_Contacts_Click:
Exit Sub

MsgBox Err.Description
Resume Exit_Additional_Contacts_Click

End Sub

Private Sub Detail_Click()

End Sub

Private Sub Exit_Click()
On Error GoTo Err_Exit_Click


DoCmd.Quit

Exit_Exit_Click:
Exit Sub

Err_Exit_Click:
MsgBox Err.Description
Resume Exit_Exit_Click

End Sub
Private Sub Close_Form_Click()
On Error GoTo Err_Close_Form_Click

Me.Undo
DoCmd.Close

Exit_Close_Form_Click:
Exit Sub

Err_Close_Form_Click:
MsgBox Err.Description
Resume Exit_Close_Form_Click

End Sub

Private Sub Form_Load()

End Sub

I also have a macro(s) that will insert all the info from the combo box into
the fields on the form. But I'm NOT updating anything here. This is just
to view what the info is.

I've also included that when you close the form you DON"T Update/Delete
ANYTHING. But it doesn't work. The properties for the fields are Locked.
In the form the properties for Allow Edits, Deletions, Additions are equal
to Yes. I tried to change this to NO and the combo box didn't work. I don't
want the form to DELETE OR ADD OR DO EDITS JUST TO DO A SEARCH!!!!!!!!

Why is this so hard to fix? Any ideas or better yet what is the solution
to this?
 
R

Rick Brandt

melwester said:
This has been ongoing for the past 2 weeks and I'm tired of having to
go into the Table and Fixing it!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I have a form with an Unbound Combo Box. Every dam time I go and run
a test on 3 companies the data gets messed up. Once this database
goes live WE DON'T WANT TO HAVE THIS KEEP HAPPENING as the Users WILL
NOT KNOW HOW TO FIX IT!!!!!!!!!!!!!!!!!

Everything that you describe suggests that the form that is being opened and
populated by your code should be an UNBOUND form. Is it? If you want to
view existing data in a BOUND form then there is no reason to have code that
populates the controls with values. You simply filter the form to the
record where those values already exist.

In your message you stated...
I also have a macro(s) that will insert all the info from the combo box into
the fields on the form. But I'm NOT updating anything here. This is just
to view what the info is.

If you open a bound form and then start assigning values to controls on that
form then you ARE changing a record. Just STOP doing that.
 
G

Guest

How do I know if the Form is Bound or Unbound? I can see if the Field is
but not the form?
 
R

Rick Brandt

melwester said:
How do I know if the Form is Bound or Unbound? I can see if the
Field is but not the form?

If it has a RecordSource property that is not blank then it is bound. If
you double-click it from the db window do you see data? If you do then it
is bound. If you don't it still "could" be bound.
 
G

Guest

OK the form is Bound as I have in the RecordSource "tbl_CTAMain". I took the
macro off. But now how do I get the data from the Combo Box into the fields
for the user to view?
 
R

Rick Brandt

melwester said:
OK the form is Bound as I have in the RecordSource "tbl_CTAMain". I
took the macro off. But now how do I get the data from the Combo
Box into the fields for the user to view?

You can open a bound form pre-filtered to a specific record by using the
WHERE argument of the OpenForm method. If you do that then I don't see why
you would have to do anything to see the field data for that record.

The controls on the form are bound to fields in the RecordSource right? If
they are then moving to the desired record should cause them to show the
data that is in that record. I don't see where the ComboBox is even
entering the picture.
 
G

Guest

Had to read this a couple of times to understand it.
The controls on the form are bound to fields in the RecordSource right? If
they are then moving to the desired record should cause them to show the
data that is in that record. I don't see where the ComboBox is even
entering the picture.

Yes - the form is bound to fields in the Record Source. But the user would
like to be able to choose which company to view hence the Combo Box. They
pick xyz company and that shows all the info for xyz. If they choose abc,
then it will show all of the company abc. I have the company field in a
(unbound) combo box on a (bound) form. I also have subforms that the
IDNumber needs to show additional info when that particular company is chosen.

So after all that I should use WHERE in Open Form? Or is there something
else I should use?
 

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