User Profile
Collapse
-
Thabnks for the various suggestions. As you say there is a workaroubnd and I have decided to adopt a similar solution. I have discovered there is no problem if the value is passed to a bound textbox - the leading zeros only get stripped when passing to an unbound textbox. Also I can't use the len(...) idea since there is not way of telling what length (i.e. number of digits) is going to be returned. However the idea of binding it to a dummy filed... -
I haven't used any formatting on the text box - somehow it assumes that the value it is being given is a number and trimming any leading zeros. (Incidentally I also tried temporarily bidning it to a text field and it then behaves properly, so the problem appears to be happening when the textbox is unbound.
I will also try your code to see what happens. It it words I can then compare all of the properties.Leave a comment:
-
Hello Lysander
Good try but this is generating an error - and yes the textbox is unbound. It's meant to generate a code for sending as part of an e-mail.
DeekayLeave a comment:
-
How to preserve possible leading zeros in a number?
Is there a way to preserve possible leading zeros in a number even when it is passed as text?
I have this code on a form which runs off a command button taking two values from user input, passing them to a function and is placing the returned value as a string back in a thrid textbox ('regNo').
The function 'generatecode' is correctly returning a string of digits which may be between 6 to 11 digits long and might contain between 0 and... -
Great - it's obvious now you've said this!!! But I was tearing my hair out becuase this part of my code seemed so straight forward.
Thanks a million
DeekayLeave a comment:
-
Hello Stewart
Thanks for the reply. Here is the code
...Code:Private Function myFunc(numInput as Double) as Double Dim fstring as String Dim numOfDigits as Byte, counter as Byte dim char(8) as String fstring = Str(numInput) For counter = numOfDigits to 1 Step -1 char(counter) = Mid(fstring, counter, 1) Next 'some more code End Function
Leave a comment:
-
How to fix overflow error message in for next loop?
I am using a straight forward For Next Loop which operates perfectly when I write
However when I change this toCode:For n = 1 to numOfDigits 'do something Next
(where numOfDigits = 8 at this point in the code)Code:For n = numOfDigits to 1 Step -1 'do the same thing as before NEXT
I am getting an error message saying 'overflow' at the For... line... -
I'm working in 2003. Here is the section of code...
...Code:Private Function dealWithErrors() Dim db As DAO.Database Dim td As DAO.TableDef Dim frm As Form Dim sec, dtl As Section Dim col As DAO.Field Dim intControlType As Integer Dim ctlLabel, ctlData, cmd1, cmd2 As Control Dim intDataXleft, intDataYtop, intDataXwidth As Integer DimLeave a comment:
-
I'm working in 2003. Here is the section of code...
...Code:Dim db As DAO.Database Dim td As DAO.TableDef Dim frm As Form Dim sec, dtl As Section Dim col As DAO.Field Dim intControlType As Integer Dim ctlLabel, ctlData, cmd1, cmd2 As Control Dim intDataXleft, intDataYtop, intDataXwidth As Integer Dim counter As Integer Dim exists As BooleanLeave a comment:
-
Thank you for your replies.
It's happening in the MDB and in a module that is called from a command button on a separate form. The command button processes other events successfully before reaching this part of the code. The code also works if I take out the line - i.e. it creates the form and then adds controls and saves the form - except that there is no header or footer of course.Leave a comment:
-
Yes - because I was calling this code from another form, I out in a 'selectobject' line - but the error message still appears at the same place.
Thanks for the suggestion - any other thoughts?Leave a comment:
-
error on acCmdFormHdrFtr - why??
I have a createForm() procedure that appears to be working and putting in controls in the detail section. I want to put the labels in the header section. As this will be a distributed .mde file I want to use vba to dynamically create the form rather than using a template. I wa using the following in order to turn on the Header (and Footer) section.
I have (after the declaring the variables)
...Code:set frm = CreateForm()
-
This usually happens when thye query that the report is based upon can't find the dates anywhere and hence asks for the dates for each individual record.
The way round this is to have a small pop-up form unbound with asks for the dates. (call it say 'askdate' with two controls boxes to enter the dates - say first_date and second_date)
Then in the first criteria of the first date put (without the quotes marks) '=form!askdate. first_date'...Leave a comment:
-
Thanks for this suggestion which I had considered. I was coming to the conclusion that this would be the case. I was trying to avoid this since I don't know the name of the table until runtime - although the variable 'tblname' picks it up.
Can I assign the record source of such a form from another form's VBA script and what is the syntax having assigned no record source upon opening? Is it
set Forms!name_of_n ew_form.RecordS ource...Leave a comment:
-
how do I change column width on table datasheet with VBA?
Help !! My code below generates error 425 'object required'. (I'm using Access 2003)
I have a table opened as a datasheet, but the column widths need adjusting programatically to fit. I have seen posts about doing this on datasheets on forms or subforms - but can I do it this way on a table opened as a datasheet? The application is being distributed as an .mde file to general users with only custom menus showing. I can't therefore use any... -
Thanks for the various contributions - have solved it now!
(Still strange that in declaring tabledefs it reverts to lowercase whereas other declarations using reserved words capitalise in some way - as has happened using a code based on Stewart's suggestion (and which works) - somthing I'm still not understanding.)Leave a comment:
-
Thank you Gershwyn and Missingling for your replies.
db.tabledefs.co unt appears to be working so that is recognized. Tabledefs is definately different to tabledef I believe where the first refers to the collection of tables and the second is used to refer to an individual table. But following on from my previous post...
str = mydefs.td.name (where str is a string variable)
is generating an error on compiling as...Leave a comment:
-
TableDefs not recognized (I think?)
I am writing some code to seen if an import error table has been created.
When using the VBA editor in Access and I type in lowerrcase the following two statements
dim db as DAO.database
dim td as DAO.tabledef
it corrects it to
Dim db As DAO.Database
Dim td As DAO.TableDef
recognising the reserved words each time. However typing
Dim mydefs As DAO.TableDefs
... -
Thanks Oralloy for your suggestion, but it didn't solve the problem.
I searched a number of forums to see if other people have had this problem with 'unsaved changes' blocking changes to proerties and whilst it's mentioned I haven't seen a solution.Leave a comment:
-
Error 2166 - how do I clear 'unsaved changes'?
I have an unbound single record form (Access 2003) that is used as a container to collect user input (name, usergroup and dates) through combos bound to three different tables. A button then processes a number of SQLs statements to add records to yet another table. This is to be distributed to non-expert users. In order to avoid processing before all the data has been entered correctly, I have locked controls and then progressively unlocked them...
No activity results to display
Show More
Leave a comment: