Inserted Textbox text into a field

  • Thread starter Thread starter m3php
  • Start date Start date
M

m3php

Guest
Hi All,

For my ICT project i have to create a access database for a plastics company.

I have designed a form for inputting customer information with txt boxes and i have put a command button on the screen to. i would like to use the command button to transfer the text into the table but i have no idea how to do this!

would someone kindly help me.

Peter
 
start by

Selecting DAO 3.6 Object Library in the references...

There after do a search for writing to a table and you should get plenty of sample code.

get yourself started and if you get stuck after, tell us where...
 
BLeslie88,

Thanks for the reply, i've done some more work on it and come up with the following code.

Code:
Private Sub Command43_Click()

  Dim UKPlasticsLimited As Database
   Dim rstCustomerInformation As Recordset
   Dim strCompanyName As String
      
   Set UKPlasticsLimited = OpenDatabase("G:\CDB.mdb")
   Set rstCustomerInformation = _
      UKPlasticsLimited.OpenRecordset("CustomerInformation", dbOpenDynaset)
   
      AddName rstCustomerInformation, strCompanyName
      

End Sub

Function AddName(rsttemp As Recordset, _
   strCompanyName As String)

   With rsttemp
      .AddNew
      !CompanyName = strCompanyName
      .Update
      .Bookmark = .LastModified
   End With
   
      End Function

It will add a blank record but no text i can see why because i have not put the inputed text into strCompanyName.

i tried "strCompanyName = txtcompanyname.text" but i get the following

Run-Time error '2185':

You cant reference a property or method for a control unless the control has focus

and when you click debug "strCompanyName = txtcompanyname.Text" is highlighted in Yellow.

any help would be great.

Kind Regards

Peter
 
Try...
Code:
strCompanyName = txtcompanyname.value

Regards,
Tim
 
exclude text

leave the .text part out.

just assign the txtbox to the field, and it should be fine.

or txtBox.setfocus then write to the field...

I only assign focus when required when i am writing, like with combo boxes sometimes and such....

when referencing .text and .value you must set focus mate.

good job btw so far.
 
Works!

Brian,

Thanks for the information, works perfect now :), just got to finish the other forms off now.

Peter
 

Users who are viewing this thread

Back
Top Bottom