Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link VB text box to Data Set

Status
Not open for further replies.

pamw85

Computer
Mar 5, 2006
1
0
0
GB
Hello!

I am trying to take the data from an edit box, edt1.text and enter it into a field Product ID in my datagrid. This will then go to my Access database. I can do the second part but not the first.

I have added in a data binding link from the edit box to the field, so when i type the data manually it will update in the database. I am thinking of using an SQL statement to do this but I can't seem to get it correct....

Any help would be great...

Pam
 
Replies continue below

Recommended for you

The data in your TextBox called ed1 are written as a character string.The max length is about 32000 characters (probably 2^15, I have not counted).In a VBa you can move this character string into a string variable, like a$=ed1.text.
With len(a$) you get the length of the string in ed1.
Alternativelly you assign to the pointer to the start point of the character string in ed1 a very large value, larger then the last character in your string, like
Let ed1.SelStart=30000
in this case it will give you back the position of the last character and you can intercept the result easily by
lastcharacter=ed1.SelStart
Again you get the length of the character string.
Maybe there is a more elegant way but I do not know it.
From now on it is routine: you should find separators among data fields( space? comma?...?)and move each group of characters that represent a single data into whatever cell you wish.
m777182
 
Status
Not open for further replies.
Back
Top