SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sending Data from Unbound field in form to table


Sending Data from Unbound field in form to table

Author
Message
sasansamani
sasansamani
Valued Member
Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)

Group: General Forum Members
Points: 61 Visits: 66
I am trying to send data from a form to a table. You click on a push button and then it sends the data to the table.

Right now I am testing. I am trying to test if I can send data from one field on the form to a field in the table but its not working. What do you recommend me to do ?

I am getting this error (Run-time error 3058). Index or primary key cannot contain a Null value.

How do I increment the primery key automatically?


Private Sub Command45_Click()


Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim varTextData As String

varTextData = Combo6

Set db = CurrentDb
Set rst = db.OpenRecordset("Waste Hauler Number", dbOpenDynaset)

rst.AddNew
rst!Classification = varTextData
rst.Update

rst.Close
db.Close

Me!Combo6 = ""

End Sub
sasansamani
sasansamani
Valued Member
Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)

Group: General Forum Members
Points: 61 Visits: 66
How do I increment the primery key automatically?


I know how do this. I need to change Primery Key in the table to autonumber.
sasansamani
sasansamani
Valued Member
Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)

Group: General Forum Members
Points: 61 Visits: 66
This is the solution.

Private Sub Command45_Click()


Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim varTextData As String
Dim varTextData2 As String
Dim varTextData3 As String
Dim varTextData4 As String
Dim varTextData5 As String
Dim varTextData6 As String
Dim varTextData7 As String


varTextData = Text31
varTextData2 = Combo0
varTextData3 = Combo2
varTextData4 = Text27
varTextData5 = Combo4
varTextData6 = Combo6
varTextData7 = Text25



Set db = CurrentDb
Set rst = db.OpenRecordset("Waste Hauler Number", dbOpenDynaset)

rst.AddNew
rst!WasteHaulerNumber = varTextData
rst!HaulerID = varTextData2
rst!Asset = varTextData3
rst!AssetNumber = varTextData4
rst!Material = varTextData5
rst!Classification = varTextData6
rst!DateYear = varTextData7

rst.Update

rst.Close
db.Close

Me!Combo0 = ""
Me!Combo2 = ""
Me!Text27 = ""
Me!Combo4 = ""
Me!Combo6 = ""
End Sub
WendellB
WendellB
Right there with Babe
Right there with Babe (768 reputation)Right there with Babe (768 reputation)Right there with Babe (768 reputation)Right there with Babe (768 reputation)Right there with Babe (768 reputation)Right there with Babe (768 reputation)Right there with Babe (768 reputation)Right there with Babe (768 reputation)

Group: General Forum Members
Points: 768 Visits: 1759
Some general information about forms in Access may be helpful as you continue your development. There are times where it is necessary or useful to use an unbound form and to force the user to click a button to save a record. However most Access forms are bound to a data source, which can be either a table or query, and in those cases you don't need any code to save a record - moving away from the record currently being added or edited automatically saves the data on the form for you. That is very useful in cases where you are using sub-forms in Access. That is also generally unique to Access - the beauty of it is that it reduces the amount of code you are required to write, and in general makes applications less complex, and thus less bug-prone.

Wendell

Wendell
Colorful Colorado
You can't see the view if you don't climb the mountain!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search