VBA OnClick -- Prompting User For More Than One Required Field
Jun 21, 2005
I'm using VBA to prompt users for two required fields. One I can do, but with more than one I get into issues like only 1 message box appearing at a time. If both fields are blank I want both messages to appear. Here's my code, it's in an On click function:
If IsNull(req_file_num) = True Then
MsgBox "Required field: File #. The appropriate file number must be entered before this PO's status can be changed to Filed."
GoTo Err_Command_158_Click2
End If
If Not [req_filed_date] Then
[req_process_status_rec_id] = 8
MsgBox "Your changes have been processed. This purchase order now has a status of Filed."
DoCmd.Close acForm, "frm_req_file"
GoTo Err_Command_158_Click2
Else: MsgBox "Required field: File Date. The appropriate date must be entered before this PO's status can be changed to Filed."
GoTo Err_Command_158_Click2
End If
Err_Command_158_Click2:
End Sub
I realize that it only shows one message box because I have the GoTo Err_Command_158_Click2 command, but I couldn't figure out how else to keep it from continuing through the code. If both "req_file_num" and "req_filed_date" are null, then I don't want the "req_process_status_rec_id" to change to 8 and have the form close.
I have a database table to which I will be adding multiple records from various other contributors. I would like to build a simple, import-friendly excel table that I can mail out to others, so that they can fill it out and send it back to me. Then I will save import steps as a macro or something similar, so that I can easily import their data.
The hard part is that I would like a way for Access to compare the new records with the existing records, identify potential duplicate records by predetermined criteria (in other words, 'wild-carded' to some level of specificity, since duplicates could be off by just a few characters), and then prompt me to examine each record to be imported alongside however many existing records that have been identified as potential duplicates. Then I as the user could:
1. accept the import record as a new record
2. decline importing that record since it is a duplicate of an existing record, or
3. edit by hand an existing record that is a duplicate of the proposed import, but may require additional information, and then decline to import the new one.After each prompt, I would like the import process to continue to the next potential duplicate, and when there are no duplicates, to complete the import and display a message box that says "Import complete".
I have a button in a form that needs to change the text in a field named idStatus from "Assigned" to "Returned"
I have tried using an expression like this "[Form]![Field]=12" in the OnClick spot but it returned an error. There is no "custom made" wizard for this and my VB skills are lacking.
Once again, thanks! (I know I post alot but this forum is amazing!)
I have a table that holds the SQL texts for ca. 1000 Select queries (mostly minor variants that are used to programmatically swap out RowSource strings for combo boxes). I'd like to have a quick and easy way to open/review/modify these queries.
One strategy would be to display the SQL strings in a field on a Datasheet form, then use an onClick event on a text box linked to the SQL-holding field (or perhaps an onClick event tied to an unbound text box on the form) to open the associated query. That would allow me to view the SQL of the query that I want to open, allow me to quickly scroll through the list of stored SQL texts, and give me options for sorting or limiting the SQL-texts displayed in the datasheet form.
But, I can't seem to get the onClick event to work. The problem seems to be that I can't figure out how to pass the SQL string contained in the field to a function that will use that string to open the query .
I have a onclick tied to a label (for decoration purposes) that when clicked it launches VBA that essentially updates a form. All that part works except it will not recognize any changed value of the field I was last in?
Just to try to explain best as I can what happens.
- Form gets opened - I change field (quantity field) - I click the Label - It reverts to pre-existing value.
if I click off of the text field first then do the onclick - it recognizes just fine.
I am trying to do something that I would think is very simple but I'm having a hard time with it. I have a form that consists of questions that the user is needed to answer. It displays the question, a combobox where the User can select 'Yes' or 'No', and a textbox where the user can input their comments. What I would like to do it the following: if the user selects 'Yes' as an answer, I want the corresponding comments box to be required.
InvNo - Autonumber (invoice number) AccNo - Clients account number Amount - Amount of invoice
I also have this data (minus the InvNo) in a linked spreadsheet. I would like to keep the spreadsheet as it is all set up for the printing of multiple copies etc.
The idea is, I want to import the data from the spreadsheet into the database, which will then apply an invoice number (because it is an autonumber), and then get that invoice number back into excel.
I have done it all, but cannot get it to give me the invoice number assigned to it.
I thought I would have a simple query that looks for records in the table that are the same account number, and amount (plus a few others I havn't included here), and then it could return the InvNo.
But, whenever I run the query, it asks me to specify the parameter, it doesn't seem to be able to read from the linked spreadsheet (it is openable, I can open it in access just fine).
In the query I have put (under criteria): "[LinkedSpreadsheet]![AccNo]" (and similar for the other fields I want to match).
Hi. I want to have all my fields on my form to be required and so that the user cant close the form if they are empty (error message). In the table properties I have them set to Required an have tried putting in a validation rule of IS NOT NULL but it still dont work. any help appreciated. thanks
Hi. I want to have all my fields on my form to be required and so that the user cant close the form if they are empty (error message). In the table properties I have them set to Required an have tried putting in a validation rule of IS NOT NULL but it still dont work. any help appreciated. thanks
Hi all Im wanting to open a sales report, but I want to be prompted to enter dates FROM and TO so that I can get specific sales.
Example
"Enter start date" here i'd enter 1/8/05 "Enter end date" here i'd enter 31/8/05
that way i'd get all sales throughtout august. Then when september comes round I could enter new dates and save me having to go in and change the filter.
Quick question for you. I know how to set a required field, but how do I edit two field so that they are dependant on each other? IE. How do I set my form to make FIELD1 required ONLY if FIELD2 is empty and vice versa? Thanks very much and I hope I've explained myself correctly.
After some suggestions, I have a form with combo boxes, the combo boxes are set to enabled "no", but become enabled by an after update command on another field.
The after update command works perfectly, however once enabled I need to ensure data is selected, as opposed to leaving blank.
I have made a form based on related tables. it requires me to fill out every field, which I don't want. I didn't make them required. Why does it do that?
I have a for form with a button to run a report. The report runs a query. The query reads data on the form to feed the report. The data that is from the table works fine but data from a text box on the form will not. It prompts for EXPR1.
In my query I have the following:
EXPR1: [Cnum]
[Forms]![FRM-Customer]![Cnum]
where FRM-Customer is the form with the button to run the report and Cnum in the text box data that I want to pass to the report. Every time I run it it prompts Cnum?
I have a report with a subreport. I have added a parameter to the query to prompt for [manager] or is null to get all managers. However, on the report when I enter a manager my count on the subreport still returns the count for all. So, I added the same prompt to the query for the subreport. It returns the right count, however, it prompts for the manager multiple times. How do I get it to prompt only once yet get the right total?
I have form "Project Log" for my table "Orders". One field "OrderTakenBy" ( text field) is a required field in the table.
In the field properities of OrderTakenBy in the Before Update event I have used the following code:
Private Sub OrderTakenBy_BeforeUpdate(Cancel As Integer)
Dim strMsg As String, strTitle As String Dim intStyle As Integer
If IsNull(Me!OrderTakenBy) Or Me!OrderTakenBy = "" Then strMsg = "You must enter your name." strTitle = "Field Required" intStyle = vbOKOnly MsgBox strMsg, intStyle, strTitle Cancel = True End If End Sub
When I first tested it, after trying to leave the field without making an entry-it worked great. Now it seems to have stopped working, I get no message when I leave the field empty.