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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading from sql

Status
Not open for further replies.

gjhman

Programmer
Oct 22, 2007
4
GB
Ok, Problem 1,
I have a linked subform in which i want to create new reords, however every method i have attempted brings me the erorr that a missing index record is needed in the main form, now this index exisists and its almost as if when i atempt to create a new record in my subform it trys to create one in the main form as well. Any suggestion of how to tackle this?? an example is below

with me.[subform].recordsetClone
.addnew
!week = 1
!resource = 4
.update
endw ith

Problem 2,
I have developed a ganett chart view in a report and need to retrieve single values from the tables, I have a sql statment that does just the job but im not sure of how i copy the value found by the sql statment into a vairable. an example of wot i want to do is

variable = docmd.runsql ("Select blar blar")
'ovb that wud be to easy

Help please!
 
How are ya gjhman . . .
gjhman said:
[blue] . . . almost as if when i atempt to create a new record in my subform it trys to create one in the main form as well . . .[/blue]
You can't have a record in a subform (child) without a related record in the main form (parent). [blue]This means you have to have the primarykey/index in the mainform first![/blue] . . . it doesn't work the other way around.

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
oh yes i know this, but iv set up watches to keep track of my primary keys and from what iv seen they all seem to be there.Iv set up watches in debug and it says hey excist there also. im using a compasit key and im suspecting its got somthing to do with that. Any ideas?

Thanks

Graham
 
How are your Child/Master links set?
Please supply the table structure for your main/child tables.

I've never had to write code for any of this--simply setting up Master/Child subforms works just fine.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Shouldn't you be adding/updating the Forcast ID in the child table?

I have no idea what you want your chart to look like. Could you provide more information?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
I can't figure out at all what you are doing. Why three little sticks going to ForecastID?

It looks like your main table as an ID field called ForecastID that is an autonumber. Then you have another table that has ForecastID as a number (key from main table) along with additional information. Right?

With that, i can't see what the big problem is. You should have a main form with the recordsource of the main table (which we still don't know the name of or what fields are in it). The subform should have a recordsource of the sub-table. The Master/Child links are FeatureID-FeatureID. There MUST be data in the FeatureId field of the Master form BEFORE you can enter data into the subform. If this isn't how you have things set up, you are going to be more specific in what you have, and what you want.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Henry Laurence Gantt, A.B., M.E. (1861-23 November 1919) was a mechanical engineer and management consultant who is most famous for developing the Gantt chart in the 1910s.

(hehe - couldn't resist)

[upsidedown]



The early bird may get the worm, but the second mouse gets the cheese in the trap.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top