473,394 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to insert values into a textbox in MS Access 2007

6
I have a problem while inserting values into textboxes. The textboxes are created dynamically. Now i would like to insert data into these textboxes and display in the form.

In the code txtday& i & k is the dynamically created textbox. I am able to create textbox. But not able to insert data into it. The above statement is working fine.
Expand|Select|Wrap|Line Numbers
  1. Forms!result!txtday.Value = days
  2.  


But i am getting error when &i & k are inserted to code. message says
" Compile error:
Expected: = "


I would like to know the syntax for inserting data.

Thanks

Expand|Select|Wrap|Line Numbers
  1. Public gv_wcnum As String
  2. Public Function get_schedule()
  3.  
  4. Dim days, shifts, total As Integer
  5. Dim i,k as Integer
  6. For i = 1 to 20
  7.   For k = 1 to 8
  8.  
  9. days = 30/3
  10. Forms!result!txtday"& i & k".value = days
  11. next k
  12. next i
  13. End Function 
  14.  
Nov 2 '11 #1
4 4433
NeoPa
32,556 Expert Mod 16PB
FNemo:
The textboxes are created dynamically.
Where? How? Please show us your code for this.

The code you have shown us is meaningless as it doesn't even compile (See When Posting (VBA or SQL) Code). Maybe it might make some sense if you posted the code that creates the TextBoxes, but alone it's without any value whatsoever (It's a bit like saying my code asdfghjk doesn't work. Well, of course it doesn't. The compiler tells you that). Without the other code it needs a properly presented question to explain what you want. This is a good attempt, but not a proper question as it stands (Frankly a good attempt is better than most so I'm happy, but a full question is required still). I can't suggest a solution to you as I don't have your question.
Nov 2 '11 #2
fnemo
6
The below program is my code. i have indicated where problem is arising.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_ok_Click()
  2.  
  3. Dim intNumOfRecords As Integer
  4.     Dim i As Integer
  5.     Dim x As String
  6.  
  7.     Dim ctltext As Control
  8.     Dim intDataX As Integer
  9.     Dim intDataY As Integer
  10.  
  11.     Dim intDataHeight As Integer
  12.     Dim intDataWidth As Integer
  13.     Dim intDataTop As Integer
  14.     Dim intDataLefy As Integer
  15.  
  16.     Dim x As Integer
  17.     Dim y As Integer
  18.  
  19.     intDataWidth = 2000
  20.     intDataHeight = 250
  21.     intDataTop = 100
  22.     intDataLeft = 100
  23.  
  24.     intNumOfRecords = 8
  25.     Data = 6
  26.  
  27.     For i = 1 To intNumOfRecords
  28.  
  29.     DoCmd.OpenForm "Search_bookid", acDesign
  30.     Set ctltext = CreateControl("Search_bookid", acTextBox, acDetail)
  31.  
  32.     With ctltext
  33.         .Name = "txtwc" & i
  34.         .Left = intDataLeft
  35.         .Top = intDataTop
  36.         .Width = intDataWidth
  37.         .Height = intDataHeight
  38.         .Visible = True
  39.  
  40.     End With
  41.     intDataTop = intDataTop + 400
  42.  
  43.     DoCmd.Restore
  44.     DoCmd.Close acForm, "Search_bookid", acSaveYes
  45.     DoCmd.OpenForm "Search_bookid", acNormal
  46.     Forms!Search_bookid!txtwc"& i".value = 8   
  47. 'this is where syntax error is coming. This is where i am inserting data into textbox
  48.     DoCmd.Close acForm, "Search_bookid", acSaveYes
  49.    Next i
  50.  
  51.    End Sub
  52.  
Nov 3 '11 #3
NeoPa
32,556 Expert Mod 16PB
I see. Sorry for the delay BTW.

Your code :
Expand|Select|Wrap|Line Numbers
  1. Forms!Search_bookid!txtwc"& i".value = 8
should be written as :
Expand|Select|Wrap|Line Numbers
  1. Forms!Search_bookid.Controls("txtwc" & i) = 8
PS. You can set the value in the design part of the code (Lines #33 to #39) too, as an alternative, if you wanted to.
Nov 11 '11 #4
fnemo
6
Thanks for the reply.
Nov 12 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: jonathandrott | last post by:
hi, i'm trying to insert a textbox value into a access database. i get an error: 'Error: no value given for one or more required parameters.' nothing is set to be required in the db. is there...
1
by: dddsssdddsss | last post by:
A comment and a question To anyone who is using conditional formatting, beware that in Access 2007 the color pallette is not the same as the color pallette in Access 2003. So if you have a...
4
by: Neil | last post by:
Just found out that the Microsoft Rich Textbox does not support full text justification, since it's based on Version 1.0 of the RichEdit Window Class, and full text justification is only available...
16
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might...
2
by: blitzztriger | last post by:
Hello!! how do i insert values into mysql , after parsing a submiting textbox?? I made the arrays, so this should be a basic insertion of them in the db, but something is missing, or in the wrong...
4
by: lupo666 | last post by:
Hi everybody, this time I have three problems driving me nuts :-((( (1) I have a report with 20 or so Yes/No "squares". Is there a way to either hide/show the "square" or change the yes/no...
9
by: prakashwadhwani | last post by:
Hi !! I'm about to develop a new project for a client. Should I go about it in Access 2003 or 2007 ? Purchasing it either for me or for my client is not a major consideration here ... what I'd...
12
by: pballou | last post by:
The is a simple example of code that worked in access 2003 but does not in access 2007. I have checked it with the debugger and the reason is the value of formField1 does not change in ver. 2007...
0
by: cowboyjunkey | last post by:
This is what I want to do: Each report page will list some details about a sample (like time sampled, where, who sampled) and below it a chart showing the distribution of the sample (i.e....
5
by: zuraberadze | last post by:
I can't connect C# to MS Access 2007 to insert data into DB. please help me. it can't see the type of db. thx
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.