Error - why dosent this form open at the correct post????

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

....

can anyone help me with this code in the not in list event - i cant get the following form to open at the new value that has been inserted..

Im using a numeric field .. maybe thats the problem.. but how can i change the code?

strSQL = "Insert Into ukjent ([Nummer]) values ('" & NewData & "')"
'MsgBox strsql

CurrentDb.Execute strSQL, dbFailOnError

FindCriteria = Me![Nummer_har rolle]
DoCmd.OpenForm "ukjent objekt", , , , , , FindCriteria

and this is the code that opens the new form:

If Not IsNull(Me.openargs) Then

Me.RecordsetClone.FindFirst "[Nummer] = " & Nz(Me.openargs)

Me.Bookmark = Me.RecordsetClone.Bookmark

Hope somone can help a newbie!

Erik
 
Im using a numeric field .. maybe thats the problem.. but how can i change the code?

strSQL = "Insert Into ukjent ([Nummer]) values ('" & NewData & "')"

Remove the ' if it's numeric: quotes are needed for Text fields but
forbidden for number fields.

strSQL = "Insert Into ukjent ([Nummer]) values (" & NewData & ")"
 
Hi Erik,

if you are opening the form "ukjent objekt" anyhow, you can get rid of the
strSQL all together and simply pass the NewData in the OpenArgs clause.
Something like:

DoCmd.OpenForm "ukjent objekt",,,,acAdd,acDialog, NewData
Response = DataErrAdded

******
Then in the Form_Load event of form "ukjent objekt," use something like:

if not isnull(me.openargs) then
me.NameOfTextControl = me.OpenArgs
end if
******
otherwise:
strSQL = "Insert Into ukjent ([Nummer]) values (" & NewData & ")"

HTH,
Jeff

can anyone help me with this code in the not in list event - i cant get
the following form to open at the new value that has been inserted..
Im using a numeric field .. maybe thats the problem.. but how can i change the code?

strSQL = "Insert Into ukjent ([Nummer]) values ('" & NewData & "')"
'MsgBox strsql

CurrentDb.Execute strSQL, dbFailOnError

FindCriteria = Me![Nummer_har rolle]
DoCmd.OpenForm "ukjent objekt", , , , , , FindCriteria

and this is the code that opens the new form:

If Not IsNull(Me.openargs) Then

Me.RecordsetClone.FindFirst "[Nummer] = " & Nz(Me.openargs)

Me.Bookmark = Me.RecordsetClone.Bookmark

Hope somone can help a newbie!

Erik
 
Hi thanks guys!

i still have a problem with getting the new form to open at the right post, am i forgetting something?

im trying to use the openargs clause..

Erik
 
John said:
strSQL = "Insert Into ukjent ([Nummer]) values ('" & NewData & "')"

Remove the ' if it's numeric: quotes are needed for Text fields but
forbidden for number fields.

Forbidden, really? I'm executing statements like

INSERT INTO transactie(transid,datum) VALUES('" & nRes & "','" & vDatum
& "');

all the time, and apparently I'm having a criminal record now? :-) Er,
[transactie] and [datum] are Long and Date fields resp.

I even thought the quotes are required for every value in VALUES. The
decimal separator for dutch numbers is a comma, so there.
 
Erik,
assuming that [Nummer] is the field name in your table, and [Nummer_har
rolle] is the name of your combo control........

If you are using the "Insert Into ...." , then you'd want to use your Where
clause to find the record in the second form you are opening.

dim FindCriteria as string
'for text datatype use this
FindCriteria = "[Nummer]='" & Me![Nummer_har rolle] & "'"
'or for numeric datatype
FindCriteria = "[Nummer]=" & Me![Nummer_har rolle]

DoCmd.OpenForm "ukjent objekt",,,FindCriteria

However, this still doesn't make sense to me. If you are opening the form
named "ukjent objekt" anyhow, perhaps to add extra data, you don't need the
where clause or the sql. Simply open the form, and fill your text control
with OpenArgs, and forget the FindFirst.

DoCmd.OpenForm "ukjent objekt",,,,acAdd,acDialog, NewData

Which method are you using?

Jeff
 
Hey Budde,

Well, I just tried it out, and it does work with the extra single quotes.
Hmmm....
I didn't even have to change the date into US format.

Win2K - US
OfficePro 2K - US
Regional Settings - Western Europe (Germany)
DateFormat - dd.mm.yyyy
comma as decimal separator

Interesting...

Jeff

Bas Cost Budde said:
John said:
strSQL = "Insert Into ukjent ([Nummer]) values ('" & NewData & "')"

Remove the ' if it's numeric: quotes are needed for Text fields but
forbidden for number fields.

Forbidden, really? I'm executing statements like

INSERT INTO transactie(transid,datum) VALUES('" & nRes & "','" & vDatum
& "');

all the time, and apparently I'm having a criminal record now? :-) Er,
[transactie] and [datum] are Long and Date fields resp.

I even thought the quotes are required for every value in VALUES. The
decimal separator for dutch numbers is a comma, so there.
 
Forbidden, really? I'm executing statements like

INSERT INTO transactie(transid,datum) VALUES('" & nRes & "','" & vDatum
& "');

all the time, and apparently I'm having a criminal record now? :-)

or... more likely... I'm posting without checking and getting it
wrong!

Thanks... learned something new today!
 
Back
Top