save record

  • Thread starter Thread starter rml
  • Start date Start date
R

rml

Can anyone tell me what might be going on with this simple code. I have this
code on a command button, it does what I want it to do. When I close the
form, it say it can't save this record. I close the form and the record is
in the table. I'm sure there is a better way to do this.

Thanks.

Private Sub Form_AfterUpdate()
If Not IsNumeric([Pos]) Then GoTo 50
[Pos2] = [Pos]
GoTo 70
50 [Pos2] = "1000"
70 End Sub
 
VBA doesn't use line numbers. I haven't see Basic with line numbers since
programming my Apple II or the XT.

Try this:

Private Sub Form_AfterUpdate()
If Not IsNumeric([pos]) Then
[Pos2] = "1000"
Else
[Pos2] = [pos]
End If
End Sub


HTH
 
Thanks, that works the same. My problem is still the same. When I close the
form, it tells me that it can't same the record at this time. If I say ok,
the form close and the records is saved in the table. I think it is a timing
issue. When I remove [Pos2] = [pos] from the code the records saves without
being prompted.

Any ideas what might be happening here?

Thanks.

Steve Sanford said:
VBA doesn't use line numbers. I haven't see Basic with line numbers since
programming my Apple II or the XT.

Try this:

Private Sub Form_AfterUpdate()
If Not IsNumeric([pos]) Then
[Pos2] = "1000"
Else
[Pos2] = [pos]
End If
End Sub


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


rml said:
Can anyone tell me what might be going on with this simple code. I have this
code on a command button, it does what I want it to do. When I close the
form, it say it can't save this record. I close the form and the record is
in the table. I'm sure there is a better way to do this.

Thanks.

Private Sub Form_AfterUpdate()
If Not IsNumeric([Pos]) Then GoTo 50
[Pos2] = [Pos]
GoTo 70
50 [Pos2] = "1000"
70 End Sub
 
all I did was edit the code you provided. Not being able to see your MDB, I
have no idea if it is a timing issue. I know nothing about your form,
controls or tables.

Basically, your code says "If the value in is not a number put the text
"1000" in [Pos2] Else put [pos] in [Pos2].

Is the data type of [Pos2] String or Number?


--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


rml said:
Thanks, that works the same. My problem is still the same. When I close the
form, it tells me that it can't same the record at this time. If I say ok,
the form close and the records is saved in the table. I think it is a timing
issue. When I remove [Pos2] = [pos] from the code the records saves without
being prompted.

Any ideas what might be happening here?

Thanks.

Steve Sanford said:
VBA doesn't use line numbers. I haven't see Basic with line numbers since
programming my Apple II or the XT.

Try this:

Private Sub Form_AfterUpdate()
If Not IsNumeric([pos]) Then
[Pos2] = "1000"
Else
[Pos2] = [pos]
End If
End Sub


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


rml said:
Can anyone tell me what might be going on with this simple code. I have this
code on a command button, it does what I want it to do. When I close the
form, it say it can't save this record. I close the form and the record is
in the table. I'm sure there is a better way to do this.

Thanks.

Private Sub Form_AfterUpdate()
If Not IsNumeric([Pos]) Then GoTo 50
[Pos2] = [Pos]
GoTo 70
50 [Pos2] = "1000"
70 End Sub
 

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

Back
Top