Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Etnering Value at one shot 1

Status
Not open for further replies.

bells

MIS
Oct 5, 2001
51
CA
I have table1 and table2

In table1 I have

stID (PK)
Name
dateOfBirth
schoolId

in table2 I have

serviceId(PK)
serviceType
stId

the two tables are related using the stID key

stID is numerical field starting 100 and I have about 200 records in the first table (The number might increase in the future)
Now, Single data entry for one person is working fine
Now what I want is that I want to enter the serviceType value for all people in table 1 with one shot
Is it possible ???
Thanks in Advance
 

Well thank you dHookom how can I do this for all stID in table1
In other words how to enter values in table2 for all stID in table1
I am sure I have to do some kind of loop but do not remember how?
I am intending to put it in a command button.

thanks
 

Hello dHookom

Yes I tried it using

Private Sub Command15_Click()

Dim strSQL As String

strSQL = "INSERT INTO table2(stId, serviceType) " & _
"Select stId from table1" & "' Me.txtServiceType'"

DoCmd.RunSQL strSQL

End sub
But when I click the button nothing happens and also nothing has entered in table2
any Idea??
Thanks for your time
 


Now I started clean and received a message

"Number of query values and destination fields are not the same" messages. any Idea ??/
 
Try:
Private Sub Command15_Click()
Dim strSQL As String
strSQL = "INSERT INTO table2(stId, serviceType) " & _
"Select stId [red], '" & Me.txtServiceType & "' from table1"[/red]
DoCmd.RunSQL strSQL
End sub

Duane
Hook'D on Access
MS Access MVP
 


Now it works fine
Thank u very much dhookom

 

Sorry for coming back again dhookom

You know this thing works perfect in Access 2003 and enters all 100 records, but after a while when I test it using Access 2007 it is inserting only one record and even with that record the [stid] value is not inserted. any idea about this. Thanks in Advance
 


The Security feature of 2007 which disables VBA, and Macros was ON. Now I disable that and Now it working perfectly well in both 2003, and 2007.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top