Hopefully I can explain this right, I have a text box (text7) that is bound to my table. This text box stores a 2 didgit code between 10 and 99 to the main table. I want to be able to use a random function =Int((99-10+1)*Rnd+10) and have the generated number output to text7 only after I initiate the onclick command for the button the function is behind. Does this require a macro to output the number to the bound textbox or is there another way that someone knows of to do this?
I have created two forms one call patient info and another called insurance on patient info form I have a text box called insurance. I want to create a event procedure whereby i could double click the box and view insurances added to database. once appropiate insurance is chosen it will display insurance name in box, any Ideas on writing code for this.
I am having a problem in my access database. I have a a form called Compliance Register. When this window opens it lists all of the requirements of a particular department. There is an ID and Source ID(this field can contain the same number such as multiple 17's). The descriptions match up to what is supposed to be shown. However when I double click on the item, it brings up a Compliance Status window. This is where things go wrong.
It shows the status listed as the first Source ID that matches the number, but does not seem to also be matching up the ID as well It must match both ID and Source ID since Source ID can have the same number multiple times down the list..
Here is what is under the Event Procedure for the double click.
Private Sub ListRequirements_DblClick(Cancel As Integer) On Error GoTo Err_ListRequirements_DblClick Dim stDocName As String Dim stLinkCriteria As String stDocName = "Compliance Status"
[Code] ......
Under stlink criteria, i need it to not only pull the ID, but it has to have a "AND" Source ID. I need it to pull the record that matches BOTH numbers.
I have just made a change to one of the forms by adding a button (by copying the only other button on the form) to cancel any changes and close the form. However, as soon as I added it I started getting the error message in the title. Please attachment LA Err1 for the full message. I also changed the caption on the other button on the form from "Close Form" to "Save && Close Form" this button is now giving the same error.
I have Compacted and repaired the DB on several occasions to no avail. I have deleted the procedures from the module and recreated them using the properties window - still get the error. I have deleted the buttons from the form and recreated the both via the object wizard and without it. Nothing I have tried has made any effect.
Often I use Labels as buttons due to the fact I can colour them the way I want, and use the on click event to trigger code. The code below however works for a command button, but not a label button.
DoCmd.OpenForm "frmdatetime" Do While Forms!frmdatetime!OKFlag.Caption = "False" DoEvents Loop
When this code is run by clicking on a command button, it works fine. If run by clicking on a label, frmdatetime opens, but the mouse will not work on either of the 2 open forms unless you go down to the windows task bar, jump onto another window, and back onto frmdatetime. If I remove the loop with the DoEvents in it, then the problem does not occur.
Can anyone enlighten me as to why this behaviour occurs.
Hi guys. i guess i am half way through. just like final step left still trying to figure it out how to create a VB procedure. anyways this is my theory and this is how much i have achieved. my God i have searched i guess every forum trying to get an answer it should'nt be that hard. I have a database. what i am trying to do is that i have a button for view reports which prompts the user to another form with 3 buttons 1) Issue(based on my query) 2) Issue Resolved(based on my query) 3) Issue not resolved(based on my query) i am using this onclick command Private Sub Issue_Resolved_Click() DoCmd.OutputTo acReport, "Issue resolved", acFormatXLS End Sub same thing for my other options. works fine but when i open the report in Excel the whole formatting is bad so with my research i found this code very valuable. a standard module code which is as folllow.
' // Generically formats a worksheet Private Sub GenericXLFormat(ByRef xlApp As Object, ByVal strDescription As String) On Error Resume Next With xlApp .Rows("1:1").Font.Bold = True .Cells.EntireColumn.AutoFit With xlApp.ActiveSheet.PageSetup .PrintTitleRows = "$1:$1" .PrintTitleColumns = "" .PrintArea = "" .LeftHeader = "" .CenterHeader = strDescription .RightHeader = "" .LeftFooter = "&""Arial""&8WF COF/SIP Database " & APP_VERSION .CenterFooter = "" .RightFooter = "&""Arial,Bold""&8CONFIDENTIAL" .LeftMargin = Excel.Application.InchesToPoints(0.5) .RightMargin = Excel.Application.InchesToPoints(0.5) .TopMargin = Excel.Application.InchesToPoints(0.8) .BottomMargin = Excel.Application.InchesToPoints(0.75) .HeaderMargin = Excel.Application.InchesToPoints(0.5) .FooterMargin = Excel.Application.InchesToPoints(0.5) .PrintHeadings = False .PrintGridlines = True .PrintComments = xlPrintNoComments .PrintQuality = 600 .CenterHorizontally = False .CenterVertically = False .Orientation = xlLandscape .Draft = False .PaperSize = xlPaperLetter .FirstPageNumber = xlAutomatic .Order = xlDownThenOver .BlackAndWhite = False .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = False .PrintErrors = xlPrintErrorsDisplayed End With End With End Sub i tried to debug it and compile it no errors. now this is what i want and i will be done. what i want is when a user clicks on my report button which is (Issue) i want this Xlformat module to be run with my onclick button. i can't find or cannot think of any procedure since my skills in VB is not that very good. all i wanted to do is create some kind of procedure with this Xlformat module so then a user will be able to save the report as an excel file and then when he opens it the report in excel should be in perfect format. columns, width should be alligned automatically. i have been searching days and night with different answers to create a template or do this and that but nothing works plz help guys. i really appreciate it. Thanks
Can someone help? I am working on an event database (based on Microsoft 2003 event database template). At present when I register attendees, I can preview an invoice which is generated based on the information I have entered.
I have set up another option to preview a Letter of Confirmation based on this same principal. As I am "Visually Basic" challenged, I simply 'copied & pasted' the event procedure and made the changes as needed to ensure the correct report was opened (ie not the Invoice report but Confirmation Letter report).
However, when I click the button to open preview the letter, the "Print Invoice" box also opens up (as it does when previewing the invoice). I don't want this box to open as I don't need to enter any details.
Can someone please have a look at my VBA event below to see what I would need to delete to stop the "Print Invoice" box from popping up.
Private Sub LOC_Click() On Error GoTo Err_ConfirmationLetter_Click If Me![Attendees Subform].Form.RecordsetClone.RecordCount = 0 Then MsgBox "Enter attendee and registration information before previewing the Confirmation Letter." Else DoCmd.OpenReport "ConfirmationLetter", acPreview, , "[RegistrationID]=" & Forms![Attendees]![Attendees Subform].Form![RegistrationID] End If
Exit_ConfirmationLetter_Click: Exit Sub
Err_ConfirmationLetter_Click: If Err <> 2501 Then MsgBox Err.Description End If Resume Exit_ConfirmationLetter_Click End Sub
Many thanks for any help. Kath Price Auckland, New Zealand
PS - Below is the original 'Preview Invoice' event that I copied: Private Sub PreviewInvoice_Click() On Error GoTo Err_PreviewInvoice_Click If Me![Attendees Subform].Form.RecordsetClone.RecordCount = 0 Then MsgBox "Enter attendee and registration information before previewing the invoice." Else DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 DoCmd.OpenReport "Invoice", acPreview, , "[RegistrationID]=" & Forms![Attendees]![Attendees Subform].Form![RegistrationID] End If
Exit_PreviewInvoice_Click: Exit Sub
Err_PreviewInvoice_Click: If Err <> 2501 Then MsgBox Err.Description End If Resume Exit_PreviewInvoice_Click End Sub
In my database I track a program called Bridge. Once you open bridge you can have anywhere from 1 to 7 "Sessions". Each bridge is assigned a number IE LT175A. If there are mulitple sessions they are numbered LT175A, LT175B, LT175C etc. I have a check box in my database that shows if bridge is installed on that PC. If it is then my section for session numbers are visiable, if bridge is not checked then the session numbers section isn't visiable. I currently have my Event Procedure in the After Update section. My code works because if I unclick on bridge my sessions disappears. However when I go to the next record if bridge is checked then my sessions are visiable but on the next record where it isn't checked it still displays the session section. So it isn't adjusting itself from record to record. Does my code need to go someplace else or am I doing something else wrong? Here is the code I have:(and it's under After Update)
This is not working however.... The table name is Response Tasks, the Column name is Response_ID and I am trying to pull the info from the one named "08". What am I doing wrong in the procedure?
Hi, I need to write a stored procedure that sits between sql server and MS access. This procedure will make sure that the queries run in access against the data in sql server will not access data for more than two years back. This is so that the queries run against the sql server do not hang up the server for too long.
I have a procedure which can put in a Restocking Charge, it works good but you have to type it in each time here it is: Dim strInput As String Dim strMsg As String strMsg = "Enter Restocking Charge?" & vbCrLf & vbLf & _ "Enter percentage." Select Case MsgBox("Is There a Restocking Charge?", vbYesNo Or vbExclamation Or vbDefaultButton1, Application.Name) Case vbYes Beep strInput = InputBox(Prompt:=strMsg, Title:="Value") Me.RestockingChg.Value = strInput Case vbNo Me.RestockingChg.Value = "" End Select I tried using the txtbox DefaultValue property and setting.DefaultValue and niether work very well. Is there a way to set the pop-up to display 15 or 15% when it opens and then be able to type over it? I can do that with a form, but the form open all ever the place and I couldn't get it to hit enter with out tabing or clicking the cmdButton. Thank you in advance to anyone helping out on this little bug. :eek:
I have implemented a logon script found in this forum - many thanks. In essance, the script opens a form with info based on a table. Could I filter the records of the form by only only including those records that are associated with the UserID of the user that just logged on?
The script: Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then MsgBox "You must enter a User Name.", vbOKOnly, "Required Data" Me.cboEmployee.SetFocus Exit Sub End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then MsgBox "You must enter a Password.", vbOKOnly, "Required Data" Me.txtPassword.SetFocus Exit Sub End If
'Check value of password in tblEmployees to see if this 'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _ "[lngEmpID]=" & Me.cboEmployee.Value) Then
lngEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo DoCmd.OpenForm "frmMain" Perhapt a filter here?????
Else MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!" Me.txtPassword.SetFocus End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1 If intLogonAttempts > 3 Then MsgBox "You do not have access to this database.Please contact admin.", _ vbCritical, "Restricted Access!" Application.Quit End If
I know this has got to be a simple reference problem, but I just can't figure it out. I am trying to pass a nested subform to a procedure, but I keep getting a type mismatch error. Here's an example:
Hi, I have a procedure in a form that I need to run on the first day of each month at 5:00 am. Is there a way or VBA codes that can get this procedure to be run automatically at that time? Thanks for any help!!!
Can you step into an Event Procedure line by line in Access? I toggled the Breakpoint at the End Sub of the Event Procedure, clicked in the middle of the sub, and pressed F8. Nothing! I do this all the time in Excel.
Try this one guys, I have a form based on a Query with Comboboxes reading a Table. the Combo's populate Textboxes with code as:
Private Sub Combobox1_AfterUpdate() Me.Textbox1=Combobox1.Column(1) End Sub
Combo bound to column 1,Row source=table. This was created in Access 2000 and works fine, but when tried in '97 Textboxes are not populating. I cannot figure out what is wrong. (Need it in '97 for work purposes)
I'm running a access 2000 adp front end working from a SQL2000 database. I've got a sproc P_insertsessions i can get this work from a cmd button on a form but i'm having problems setting the paramerters i want it to use controls on the form. @contractid = contractid @start_date = startdate @end_date = enddate @hours = duration
I have a large search form, in which I am building a query in the code.
I went to compile the code, and was suprised to receive the error "Code too long for procedure". I had no idea there was a limit, but now I know.
So, I believe I will have to break this code up into chunks, stored on at least one if not more code modules, and call the functions.
To do this, I would have to pass the values entered into the form, to the code module. Build that portion of the query Where Clause, and then return that string value back to the code on the Search form.
Has anyone attempted this before? If so, could you give me a small example of how to pass a value from a form, to a code module, process it on the code module, then pass a resulting value from the code module back to the code in the form.
I am trying to figure out how to manipulate the On Delte event of a subform. I can delete the record but I need to have fields on the main form reflect the changes. Can any one help me?
Error Message: The expression On Delete you entered as the event property setting produced the following error: A problem occurred while Microsoft Access was communicating with the OLE server or ActiveX Control. *The expression may not result in the name of a macro, thename of a user-defined function, or [Event Procedure]. *There may have been an error evaluating the function, event, or macro.
Basically I think this message is telling me that I can not modify the deleting procedure as I wish too. If this is true can you tell me where I can do that.
here is the very basic code that i am using.
This is the subform code Option Compare Database Dim main As Form_frmOrders
Private Sub Form_Delete(Cancel As Integer) On Error GoTo err Dim wght As Double Dim pallet As Double wght = .Total_Weight.Value pallet = main.Total_Pallets.Value If Weight.Value <> 0 Then wght = wght - Weight.Value MsgBox wght Else pallet = pallet - Quantity.Value MsgBox pallet End If err: MsgBox err Exit Sub End Sub
I created a button on a form that executes a procedure: MyButton_Click(). The button works fine.
Now I want to have a menuitem execute the same procedure, but when I fill in the OnAction property with MyButton_Click(), =MyButton_Click(), Me.Form.MyButton_Click(), and any number of other combinations, and then click on the menuitem, I am told that Access "can't find the function".
Is this just a matter of specifying the procedure correctly, or what?
I am using unbound forms and multiple recordsets to save data into a number of tables. The save procedure is two parts: the first one saves data from a temporary table tblT to tblA. Second part takes the primary key of this new record in tblA and stores it with additional data in tblB.
In case there is an error, this procedure creates all kinds of problems. Usually the errors happen in the second part of the code and by then the data has already been saved in the tblA. On Error, the sub exits. When the user makes changes in the info and retries to save, the sub again tries to save data from the tblT to tblA, but now runs into primary key problems as the data already exists! (the reason for this is because the primary key field for tblA is filled with an autonumber generated by tblT).
Ideally, on error, the sub should delete the last record (or two or three, as the case may be) from tblA so that they can be re-stored by the sub on resumption. I cannot get either an SQL statement or a recordset to identify exactly these records to delete them. All help is highly appreciated! Also, any suggestions towards alternative methods of achieving this are most welcome!