Simple update query / form question

W

wazza_c12

HI There

I have a little database project for my internship that is so close to
finished, I have one last hurdle before either my brain explodes or I
get it done.

I have a display form showing a record, it has an edit command button
that opens another form to the same record.

On this second editing form I have all the boxes unbound so that the
user can change what they want then hit an "update" button to do the
updating, or a cancel button if they desire.

I'm having problems getting this update query working properly (that
the update button calls)

I currently have

UPDATE Details SET Field1 = Forms!Edit_Record!Field1
WHERE ID = Forms!Edit_Record!ID

It's completely not working.

Am I using a subform? do I have to add that to the path? ie.
Forms!Display!Edit_Record!ID

ID (my primary key) is not actually on the form, but is still part of
the current record (I assume) how do I reffer to it? is that the
problem?

Thankyou for any help, I'm sure this is the most simple question
posted, I've just been sitting at the PC too long

Thanks in advance

Warwick
 
R

Rick Brandt

HI There

I have a little database project for my internship that is so close to
finished, I have one last hurdle before either my brain explodes or I
get it done.

I have a display form showing a record, it has an edit command button
that opens another form to the same record.

On this second editing form I have all the boxes unbound so that the
user can change what they want then hit an "update" button to do the
updating, or a cancel button if they desire.

I'm having problems getting this update query working properly (that
the update button calls)

I currently have

UPDATE Details SET Field1 = Forms!Edit_Record!Field1
WHERE ID = Forms!Edit_Record!ID

You have this where? In a query? In VBA code?
It's completely not working.

Am I using a subform? do I have to add that to the path? ie.
Forms!Display!Edit_Record!ID

ID (my primary key) is not actually on the form, but is still part of
the current record (I assume)

Why would you assume it's "in the record"? Unbound forms don't have a record.
Sort of the point of an unbound form actually. Unless you have some hidden
controls what you see is what you've got.

With your unbound form open type each the following into the immediate window
one at a time...

?Forms!Edit_Record!Field1 <Enter>

?Forms!Display!Edit_Record!ID <Enter>

Do they return a value? Are they what you expect?
 
W

wazza_c12

UPDATE Details SET Field1 = Forms!Edit_Record!Field1
WHERE ID = Forms!Edit_Record!ID


You have this where? In a query? In VBA code?

It is in a query called by a command button
It's completely not working.
Am I using a subform? do I have to add that to the path? ie.
Forms!Display!Edit_Record!ID

ID (my primary key) is not actually on the form, but is still part of
the current record (I assume)



Why would you assume it's "in the record"? Unbound forms don't have a
record.
Sort of the point of an unbound form actually. Unless you have some
hidden
controls what you see is what you've got.

Well I used a command button wizard to establish the link between the
first and second forms, the second form has a control source of my
details table and a filter set to whatever record ID I'm editing. .....
It is just that I chose not to bind my fields on that form, they are
populated by code when the command button is pressed on first form

With your unbound form open type each the following into the immediate
window
one at a time...


?Forms!Edit_Record!Field1 <Enter>


?Forms!Display!Edit_Record!ID <Enter>


Do they return a value? Are they what you expect?

No values

Hope that clears things up a little
Cheers
 
R

Rick Brandt

Rick said:
Actually looking again the second reference has too many bangs (!). It should
be...

Forms!FormName!FieldName
(two bangs)

Why do you have "Display" in there?

Never mind. I see now that I was the one with the erroneous !Display in there.
I have no idea where that came from. Anyway if you entered your reference
correctly into the immediate window then you should get your value.
 
W

wazza_c12

Der....

Thanks for the help, 30mins away from PC does wonders

Looks like the problem was that as I experimented and changed my query
I did not close it, which caused errors when I tested my form.

If I played with the query, closed it, then tested the form I got the
results I was after

Thanks for the help ......

If all else fails, go make a coffee
 
Top