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

Numbers with decimals in access

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello!

Is there any way to store a number with decimal points in access? eg: 6.59? And following is the code behind the add button of a form. It works but the data in the form remains even after it is added. i.e the form won't reappear empty. Can anyone help me regarding these?


Private Sub Add_Click()
On Error GoTo Err_Add_Click
Dim i

DoCmd.GoToRecord , , acNewRec
Me!Text23 = ""
Me!Text45 = ""
Me!City = ""
Exit_Add_Click:
Exit Sub

Err_Add_Click:
If Err.Number = 3022 Then
i = MsgBox(" The Student ID Has To Be Unique", vbOKOnly, "Student Database")
Else
MsgBox Err.Description
Resume Exit_Add_Click
End If

End Sub
 
Hello! Might try setting any fields where you need decimals to "Single" or "Double" Field Size. You can then set the Format and Decimal places properties as you choose.

Your code:

Private Sub Add_Click()
On Error GoTo Err_Add_Click

DoCmd.GoToRecord , , acNewRec
'Me!Text23 = ""
'Me!Text45 = ""
'Me!City = ""
Exit_Add_Click:
Exit Sub

Err_Add_Click:
If Err.Number = 3022 Then
MsgBox "The Student ID Has To Be Unique", vbOKOnly+VbInformation, "Student Database"
Else
MsgBox Err.Description
Resume Exit_Add_Click
End If

End Sub

I don't know what you're doing setting the fields to an empty string? Check what the "default value" is for each of these fields. Either on the form, or in the table. (probably 0?) Just leave them empty. Give it a try,

Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top