Ok I am exporting some data to a plain text file and one of the fields I am outputing can vary in the number of characters and I need they to have the same number of characters all the time.
Ex: 123.00 => 000012300
456789.00 => 045678900
I had heard of a command, but I can't remember what it was...I could do a loop till LEN() = 9 but that would cause undue clock cycles (aka performance hit) on the machine when running through the export routine.
Hello, I was wondering if you have one or have seen a routine to generate unique username from first, middle and last names. Here is my requirement - by default first initial and last name of a user is their username. But if the expected or default username is already taken then if the user have middle initial, then the username for this user would be first initial, middle initial and lastname. If the user does not have middle name then the username for the user would be first two letters of first name and lastname and if that's already taken then first three letters of first name and last name and so on.
I was wondering is it possible to schedule in windows somewhere to open up my syncfrontend.mdb and then run a routine that i have written inside of that mdb.
The routine is a huge database syncronisation task that needs running every hour, it's all there ready to be run but just need a way to get to it and run it automatically on the hour every hour.
Hi guys, I was looking for a way to trap err.number 3314 (when required field is null) before Jet generates its warning. I came across an old post from Rich (below), but I couldn't make it work as yet. In the calling form, under the Form_Error event I wrote the following:
Dim f As Form Set f = Me Call fnValidateForm(f)
Could anyone please tell me where my error lays here? I have several forms which have several text and/or combo boxes bound to required fields and I would want to have a generic code, like the one here to trap errors before Jet shows it's Error Message.
Thanks in advance Regards Jaime Premy - Belém-Brasil
******************Rich's Function******************** Public Function fnValidateForm(frmA As Form) As Boolean Dim ctl As Control Dim Msg, Style, Title, Response, MyString fnValidateForm = True For Each ctl In frmA.Controls 'value in the control is required If InStr(1, ctl.Tag, "Required") > 0 Then ' no value entered or value is null ' or zero for numeric fields If (IsNull(ctl.Value)) Or (Len(ctl.Value) = 0) Then ctl.SetFocus MsgBox "You have not entered all the required fields return to the record and correct this! The record will not be saved if you do not! " fnValidateForm = False
Exit For End If
If InStr(1, ctl.Tag, "NumberRequired") > 0 Then If ctl.Value = 0 Then ctl.SetFocus MsgBox "You have not entered all the required fields return to the record and correct this! The record will not be saved if you do not! " fnValidateForm = False
I have a subroutine which cycles through all controls on a form, and for controls with applicable tags, either enables or disables the control.
The routine accepts a form as the parameter (frm), and is called from a button on the form itself.
Despite trying frm.repaint in the generic routine, and, me.repaint from the calling form, the controls do not seem to repaint until the mouse moves over them. A command button, for example, will be grey-ed out, despite being enabled, but will un-grey when the mouse goes over it.
I have a public sub routine which requires parameters to be passed to it when I call it from an access form. When I try to enter the code to call the sub I get a compile error. I've also tried calling it from another sub in the same module but get the same compile error - see below.
Code: Sub EmailData(Datafile As String, To_mail As String, CC_mail As String, Subject_mail As String) 'code to use variables passed in End Sub
I have 28 combo boxes on a form, which I want to insert data into the table as they are changed. Each one will pass the same sets of data just with different parameters which come from the form.
Rather than putting the same code to insert on each of the 28 combo boxes I thought it would be easier to create a function to do it and pass the parameters to it through a sub on the AfterUPdate event of the combo box.
I need to pass 4 parameters, if I only put 1 in there it works fine, but when I start putting more in it doesnt work and I get compile errors or syntax errors.
Sub routine:
Code: Private Sub cboMonday1_AfterUpdate() If Me.cboMonday1 = 1 Then Me.cboMonday1.BackColor = vbGreen Me.cboMonday1.ForeColor = vbBlack
I have a query that runs based on a parameter a user selects on a form.
I want to dynamically create the sendobject file name based on the parameter the user selects.
Example:
My form has a parameter named medicine. When the user checks the checkbox next to medicine it runs a query for records labeled as medicine but sends the e-mail output as the query name. I want something like medicine.txt etcc...
I am trying to call a subroutine from a VBA routine to append a record to an existing table. Below is the code for opening my recordsets for reading followed by the code creating my table to append to:
Public Sub UpdateLotsizes() Dim curDatabase As DAO.Database Dim ProdPlanDB As DAO.Database Dim rstQryLot As DAO.Recordset Dim rstInvLoc As DAO.Recordset Set curDatabase = CurrentDb
[Code] ....
To call my subroutine, I simply put in the code:
ExceptionReportAddRecord
And this is the code of the subroutine:
Public Sub ExceptionReportAddRecord() Dim rstExcRpt As Recordset Set rstExcRpt = curDatabase.OpenRecordset("tblExceptionReport") With rstExcRpt .AddNew .Fields("item_no").Value = txtItemNumber
[Code] .....
I am receiving "Run-time error 434: Object required" at the line I marked with ...
I have a small database where we enter audit log data. In my add add screen from the switchboard, one of the fields is the user the audit is assigned to. So that our group wouldn't be typing their names a bunch of different ways I created a reference table called "Ref Data 005 - Contact Name". So i pre-populate the Contact Names such that they will be more consistent.
The add works perfectly. I built all my screens using the forms wizards.
Now for the modify routine. If the user wants to go in an modify one of the other data elements, I force them in the wizard to do this modify by choosing thier name. Therefore, when i built this screen using the wizard I reference the "ref table" mentioned above. I then throw open another form displaying all of the fields based on the records that it finds for that user when they choose the name from the Ref data 005 table. Hope that makes sense. Ie.. they choose the records they want to possibly modify by first choosing their name from the ref table.
It correctly pulls the records for whatever user you choose. However, when you make the update and save, it is changing the Ref table name as well.
So for example if three users were in my ref as : bill joe john
And you launch the form, lets say joe shows up in the list, when i change it to bill to retrieve bill's records , it will do that but when i make the change, then Joe is changed to bill in the reference table.
The problem is lately; while testing I am running multiple queries in a routine. When it fails; its hard to identify which query has the problem. So I hit control break; debug and try to find it. After I fix it; I debug and reset; i get this continuing hourglass thing in the form of a spinning circle until I close and reopen the database. I think I need better error handling but not something really complicated because I need to put it in quite a few routines throughout the database.
Hello, Does anyone knows how can I export the export/import specifications (which file/directory) and how can I import/export the specifications between different versions of Access. Thanks!
This may be a real dumb question but is there any way to view/edit an existing export specification for the transfer text macro? I'm reviewing someone else's database and can't figure out how to view it.
When I export a query to xml (MS Access) then the name of the query equals the tagname in xml. Example: when the queryname is ‘qryRegions’, the xml result is:
Hi: I want to automate the XML export function of Access and not sure if it is possible or how to do it. In going through the menu bar (File ->Export) interface, I must choose the root table, and then subsequent tabbed windows allow one to select what tables to be exported, if I want the schema to be generated, the target filename, etc. Instead of having to go through this large selection process, I'd like to write a script that I can run consistently over the same tables, produce the same file name, etc. Can anybody provide a suggestion/code/pointer on how to accomplish this? Thanks in advance. John
I have one workstation that errors when code get to a line where I try to export a report to an rtf file. The error message says something like 'Cannot execute export command'. It works on other workstations and I can even manually export the report to an rtf file - Any ideas?
Hey all, I'm working on an invoice system in Access and I had just wondered if there was a way I could export a form to a format I could distribute to clients? (pdf, html...etc) thanks!
I'm trying to find a way to export the structure of a table in my Access database.
I created a new table and I want to put it in the database on my website. However, my site is constantly being used so I have no way of downloading the database, modifying it, and then uploading it again without losing some data.
I do have a database editor on my website that allows me to run queries. So If I can get a query with all of the CREATE TABLE information (all the fields, whether they are Allow Zero Length, etc.) then I can just use that.
I can't seem to find a way in Access 2000 to export the structure of the table.
I would like to output them into a text file as "A0010", "N0103", "C0123"
Background is that I have set up a DB that connects to an Oracle DB and where we have an email address for a client it emails a PDF file to that client.
Prior to this emailing we used Crystal and we will continue to do so for those without email, the format above is Crystal Filter and I can copy paste the above straight into a filter blocking them from creating a printed statement.
Ok forgive me I'm a newb. I curently have a query in access that I'm trying to make a button to automatically send the results of this query to excell. When I run the code (below) it gives me a compile error saying user defined type not found on the highlighted portion
Private Sub ExporttoX_Click() On Error GoTo Err_ExporttoX_Click
Dim db As DAO.Database Dim rs As DAO.Recordset 'Set db = DAO.DBEngine.Workspaces(0).OpenDatabase( _ "C:database.mdb") Set db = CurrentDb Set rs = db.OpenRecordset("qbpexcel", dbOpenSnapshot)
'Start a new workbook in Excel
Dim oApp As New Excel.Application Dim oBook As Excel.Workbook Dim oSheet As Excel.Worksheet
Set oBook = oApp.Workbooks.Add Set oSheet = oBook.Worksheets(1)
'Add the field names in row 1 Dim i As Integer Dim iNumCols As Integer iNumCols = rs.Fields.Count For i = 1 To iNumCols oSheet.Cells(1, i).Value = rs.Fields(i - 1).Name Next
'Add the data starting at cell A2 oSheet.Range("A2").CopyFromRecordset rs
'Format the header row as bold and autofit the columns With oSheet.Range("a1").Resize(1, iNumCols) .Font.Bold = True .EntireColumn.AutoFit End With
oApp.Visible = True oApp.UserControl = True
'Close the Database and Recordset rs.Close db.Close
I have searched the forums for similar problem but I was unable to find it.
I have some buttons that export the data from a form into a Word Document. It generally works but there are some issues.
I have Access 2003 but the people using it only use the runtime version of Access and the environment is Office 2000.
I have copied code from other examples and maybe missing something that is causing the issues.
1. When I export the record it is causing problems with the Normal.dot template. When I try to close Word it keeps asking me that I have modified that template. After pressing Cancel button twice it the save box disappears. 2. When I leave the code Dim objWord As word.Application I get an error message about a compile error User defined Type not defined. 2. When the users try to export a record to the specific word template I created and a required field is empty an error message is displayed and then closes the application.
Any help will be appreciated. I am a newbie when it comes to code.
Sample code is below. Private Sub Command1079_Click() Dim objWord As word.Application 'Start Microsoft Word 2000. Set objWord = CreateObject("Word.Application")
With objWord 'Make the application visible. .Visible = False
'path and name of the template your are using. ' objWord.Documents.Add ("U:Asset Strategy and Commercial PropertyCommercial PropertyTaskmasterletterofobjection.dot") .Documents.Open ("C:Documents and SettingsDadMy DocumentsWorkTaskmasterletterofobjection.dot")
'This is for the bookmark that you created in the template
Print_Reconsideration_Err: 'If a field on the form is empty, remove the bookmark text, and 'continue. If Err.Number = 94 Then .Selection.Text = "" Resume Next
End If objWord.Application.Options.PrintBackground = False objWord.Application.ActiveDocument.PrintOut