Disappearing data in Tables

G

Guest

I have a main form with tab control subforms. When I click on my dropdown
box in the main form to pick "companies" the first one comes up fine. So I
check the second- fine as well. But if I click back on the first one I get
an error message saying city is missing. I go to the table and this is what
is happening:

Table dropdown box has companies:

Name Address
Alpha Omega 400 Oakdale Dr.
Benecare 500 Helendale Road, Suite 175
Better Business Bureau 150 State St.

When I get to the 3 test where I go back to see the 1st one - this is what I
see in the table:

Name Address
150 State St, Suite 175 Suite 175
150 State St, Suite 175
Better Business Bureau 150 State St.

This should NOT happen!!!!

The names of companies are being replaced by address of the 3rd company.
WHY??????

Here is my source code (which isn't much):
Option Compare Database

Private Sub Additional_Contacts_Click()

End Sub

Private Sub Form_Load()


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


DoCmd.Close

Exit_Close_Form_Click:
Exit Sub

Err_Close_Form_Click:
MsgBox Err.Description
Resume Exit_Close_Form_Click

End Sub

Private Sub sfrm_CTAContactsView_Enter()

End Sub

Private Sub sfrm_CtaNotesView_Enter()

End Sub

The Record Source is tbl_CTAMain
Allow Filters=Y
Single Form
Views Allowed=Both

Any ideas as to why this is happening?
 
D

Dirk Goldgar

melwester said:
I have a main form with tab control subforms. When I click on my
dropdown box in the main form to pick "companies" the first one comes
up fine. So I check the second- fine as well. But if I click back
on the first one I get an error message saying city is missing. I go
to the table and this is what is happening:

Table dropdown box has companies:

Name Address
Alpha Omega 400 Oakdale Dr.
Benecare 500 Helendale Road, Suite 175
Better Business Bureau 150 State St.

When I get to the 3 test where I go back to see the 1st one - this is
what I see in the table:

Name Address
150 State St, Suite 175 Suite 175
150 State St, Suite 175
Better Business Bureau 150 State St.

This should NOT happen!!!!

The names of companies are being replaced by address of the 3rd
company. WHY??????

Here is my source code (which isn't much):
Option Compare Database

Private Sub Additional_Contacts_Click()

End Sub

Private Sub Form_Load()


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


DoCmd.Close

Exit_Close_Form_Click:
Exit Sub

Err_Close_Form_Click:
MsgBox Err.Description
Resume Exit_Close_Form_Click

End Sub

Private Sub sfrm_CTAContactsView_Enter()

End Sub

Private Sub sfrm_CtaNotesView_Enter()

End Sub

The Record Source is tbl_CTAMain
Allow Filters=Y
Single Form
Views Allowed=Both

Any ideas as to why this is happening?

I don't think that can be all the relevant code. There's nothing there
that will do anything at all when a selecttion is made from a combo box.
The only code there that will do anything are two Click routines that
will close the form or exit Access, respectively. Are you executing a
macro in one of the combo box's events? Is there code in any of the
events of the subforms?
 
G

Guest

Here's the macro:

Function mcrCTAMainTextBox()
On Error GoTo mcrCTAMainTextBox_Err

' Set the Number
Forms!frm_CTAMainView![Number_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(1)
' Set the Address
Forms!frm_CTAMainView![CTAAddress_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(2)
' Set the City
Forms!frm_CTAMainView![CTACity_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(3)
' Set the State
Forms!frm_CTAMainView![CTAState_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(4)
' Set the Zip
Forms!frm_CTAMainView![CTAZIP_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(5)
' Set the Phone
Forms!frm_CTAMainView![CTAPhone_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(6)
' Set the Fax
Forms!frm_CTAMainView![CTAFax_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(7)
' Set the Email
Forms!frm_CTAMainView![CTAEmail_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(8)
' Set the Region
Forms!frm_CTAMainView![CTARegion_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(9)
' Set the Eligibility
Forms!frm_CTAMainView![CTAEligibility_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(10)
' Set the Reopening-1
Forms!frm_CTAMainView![Reopening1_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(11)
' Set the Reopening-2
Forms!frm_CTAMainView![Reopening2_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(12)
' Set the Contact Name1
Forms!frm_CTAMainView![CName1_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(13)
' Set the Contact Phone1
Forms!frm_CTAMainView![CPhone1_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(14)
' Set the Contact Fax1
Forms!frm_CTAMainView![CFax1_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(15)
' Set the Contact Email1
Forms!frm_CTAMainView![CEmail1_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(16)


mcrCTAMainTextBox_Exit:
Exit Function

mcrCTAMainTextBox_Err:
MsgBox Error$
Resume mcrCTAMainTextBox_Exit

End Function

Now I can't even get the dropdown box to work. It won't let me click on
anything.
 
D

Dirk Goldgar

melwester said:
Here's the macro:

Function mcrCTAMainTextBox()
On Error GoTo mcrCTAMainTextBox_Err

' Set the Number
Forms!frm_CTAMainView![Number_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(1)
' Set the Address
Forms!frm_CTAMainView![CTAAddress_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(2)
' Set the City
Forms!frm_CTAMainView![CTACity_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(3)
' Set the State
Forms!frm_CTAMainView![CTAState_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(4)
' Set the Zip
Forms!frm_CTAMainView![CTAZIP_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(5)
' Set the Phone
Forms!frm_CTAMainView![CTAPhone_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(6)
' Set the Fax
Forms!frm_CTAMainView![CTAFax_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(7)
' Set the Email
Forms!frm_CTAMainView![CTAEmail_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(8)
' Set the Region
Forms!frm_CTAMainView![CTARegion_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(9)
' Set the Eligibility
Forms!frm_CTAMainView![CTAEligibility_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(10)
' Set the Reopening-1
Forms!frm_CTAMainView![Reopening1_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(11)
' Set the Reopening-2
Forms!frm_CTAMainView![Reopening2_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(12)
' Set the Contact Name1
Forms!frm_CTAMainView![CName1_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(13)
' Set the Contact Phone1
Forms!frm_CTAMainView![CPhone1_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(14)
' Set the Contact Fax1
Forms!frm_CTAMainView![CFax1_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(15)
' Set the Contact Email1
Forms!frm_CTAMainView![CEmail1_Text] =
Forms!frm_CTAMainView![CTAName-Combo].Column(16)


mcrCTAMainTextBox_Exit:
Exit Function

mcrCTAMainTextBox_Err:
MsgBox Error$
Resume mcrCTAMainTextBox_Exit

End Function

Now I can't even get the dropdown box to work. It won't let me click
on anything.

This is not a macro, as Access uses the term -- it's a VBA procedure.
Why didn't you post it with the original code?

I strongly suspect that this code is wrongly conceived. If your form is
bound to the table, this code will modify the data for the current
record every time you ake a new choice in your combo box. Is that
really what you mean to do? I don't mean that your form will find and
display the newly chosen record, I mean that the current record will
actually be changed!

Is your form bound? That is, does it have a non-blank RecordSource
property? If so, I think your combo box doesn't do what you think it
does, and you'd better fix it before you wipe out all your data.
 

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

Similar Threads


Top