If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
List Box to Open Form
I see the module listing on the left side to where code is entered. The
procedure is listed under "Modules". I clicked the heading "Class Modules" and all the associated forms opened. I opened "fWorkLog" form (where my calculated time field is located) and the command buttons, etc. associated with this form opened but not the procedure listed below. So it's not in both places, correct? I'm not very good with code - can figure a few thing out with cut & paste. Your help with this is very much appreciated!!! "tina" wrote in message ... did you have the procedure in a form's module, and then add it to a standard module - without deleting it from the form's module? if so, delete the procedure from the form module; you don't need it in both places. hth "Pam" wrote in message ... I went to Modules on the left side of the db window, clicked New and pasted the code in. I've changed the name several times and keep getting "The expression contains and ambiguous name. You may have two or more functions with the same name in different modules. Rename the functions so that each one has a unique name". The first time I did this with the Elapsed Time String it worked really well. "tina" wrote in message ... did you put the function in your form module? if so, try putting it in a standard module. make sure you don't give the module the same name as the procedure. hth "Pam" wrote in message ... Tina, Thank you so much for the prompt reply and it worked very well. Would you mind looking at the following code and letting me know what I'm doing wrong. I have set fields "StartTime" and "StopTime" and can get it to calculate on a field with an Elapsed Time String code for each record on a datasheet. I want to total the amount of time for the total job and have set up the following "HoursAndMinutes" module code. When I enter =HoursAndMinutes([StartTime]-[StopTime]) OR =HoursAndMinutes(Sum([StartTime]-[StopTime])), I get the msg "The object doesn't contain the Automation Object 'HoursAndMinutes' Public Function HoursAndMinutes(interval As Variant) As String '************************************************* ********************** ' Function HoursAndMinutes(interval As Variant) As String ' Returns time interval formatted as a hours:minutes string '************************************************* ********************** Dim totalminutes As Long, totalseconds As Long Dim hours As Long, minutes As Long, seconds As Long If IsNull(interval) = True Then Exit Function hours = Int(CSng(interval * 24)) totalminutes = Int(CSng(interval * 1440)) ' 1440 = 24 hrs * 60 mins minutes = totalminutes Mod 60 totalseconds = Int(CSng(interval * 86400)) ' 86400 = 1440 * 60 secs seconds = totalseconds Mod 60 If seconds 30 Then minutes = minutes + 1 ' round up the minutes and If minutes 59 Then hours = hours + 1: minutes = 0 ' adjust hours HoursAndMinutes = hours & ":" & Format(minutes, "00") End FunctionThe help is greatly appreciated!!"tina" wrote in message ... if there is a possibility that a record will have Receiving data entered, but not Disassembly data entered, *when you move to that record*, then change the Current event to If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If again, if you don't want the pop-ups on new blank records, then change the above to If Not Me.NewRecord Then If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If End If aside from the above, add the following code to the Receiving control's AfterUpdate event, as If IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If hth "PHisaw" wrote in message ... Tina, Thanks for the help! It worked, but can you now tell me how to keep a second popup from opening if it has null values. Ex: If "Receiving" is null, per your code below, it opens. I have another popup based on field "Disassembly" being null. I don't want both of them to open up when my main form opens, only "Receiving" and then when it is no longer null have "Disassembly" start opening. Is this possible? "tina" wrote: try adding code to the Current event of fGeneralInfo, as If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" End If if you only want the pop-up to open on existing records (not a new, blank record) then use If Not Me.NewRecord And IsNull(Me!Receiving) Then hth "Pam" wrote in message ... Tina, I got it to work - thanks so much! Can you help me open a pop up form already created based on a field being blank on another form? Ex: "fGeneralInfo" has field "Receiving". If "Receiving" is blank, I want form "fPopUpReceiving" to pop-up when fGeneralInfo opens with job info. I hope this isn't too confusing! Once again, the help is greatly appreciated!! "tina" wrote in message ... What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? do you mean "open *another* form" for the specific job number? if so, you can run code from the listbox control's Click event or AfterUpdate event to open the form with a WHERE clause, something along the lines of DoCmd.OpenForm "FormName", , , "JobNumber = " _ & Me!ListBoxName if the job number is a Text field, rather than a Number field, the syntax would be DoCmd.OpenForm "FormName", , , "JobNumber = '" _ & Me!ListBoxName & "'" in either case, the assumption is that the job number field is the bound column in the listbox control. hth "Pam" wrote in message ... I have a combo box and a list box on a form. The combo box lists tech names from a tech list table. The list box lists jobs related to each tech as they are selected in the combo box. What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? Any help is greatly appreciated!! Thanks, Pam |
#12
|
|||
|
|||
List Box to Open Form
in any module, from the menu bar click Edit | Find. in the Find dialog, in
the Search section, choose Current Project, so all modules in the database will be searched. if you don't "find" another procedure with the same name, great. again, make sure that the standard module holding the procedure does *not* have the same name as the procedure. then, suggest you compile the code by clicking Debug | Compile from the menu bar; fix any errors that come up. then close any open objects (forms, modules, whatever) and compact/repair the database. then try running the function again. hth "Pam" wrote in message ... I see the module listing on the left side to where code is entered. The procedure is listed under "Modules". I clicked the heading "Class Modules" and all the associated forms opened. I opened "fWorkLog" form (where my calculated time field is located) and the command buttons, etc. associated with this form opened but not the procedure listed below. So it's not in both places, correct? I'm not very good with code - can figure a few thing out with cut & paste. Your help with this is very much appreciated!!! "tina" wrote in message ... did you have the procedure in a form's module, and then add it to a standard module - without deleting it from the form's module? if so, delete the procedure from the form module; you don't need it in both places. hth "Pam" wrote in message ... I went to Modules on the left side of the db window, clicked New and pasted the code in. I've changed the name several times and keep getting "The expression contains and ambiguous name. You may have two or more functions with the same name in different modules. Rename the functions so that each one has a unique name". The first time I did this with the Elapsed Time String it worked really well. "tina" wrote in message ... did you put the function in your form module? if so, try putting it in a standard module. make sure you don't give the module the same name as the procedure. hth "Pam" wrote in message ... Tina, Thank you so much for the prompt reply and it worked very well. Would you mind looking at the following code and letting me know what I'm doing wrong. I have set fields "StartTime" and "StopTime" and can get it to calculate on a field with an Elapsed Time String code for each record on a datasheet. I want to total the amount of time for the total job and have set up the following "HoursAndMinutes" module code. When I enter =HoursAndMinutes([StartTime]-[StopTime]) OR =HoursAndMinutes(Sum([StartTime]-[StopTime])), I get the msg "The object doesn't contain the Automation Object 'HoursAndMinutes' Public Function HoursAndMinutes(interval As Variant) As String '************************************************* ********************** ' Function HoursAndMinutes(interval As Variant) As String ' Returns time interval formatted as a hours:minutes string '************************************************* ********************** Dim totalminutes As Long, totalseconds As Long Dim hours As Long, minutes As Long, seconds As Long If IsNull(interval) = True Then Exit Function hours = Int(CSng(interval * 24)) totalminutes = Int(CSng(interval * 1440)) ' 1440 = 24 hrs * 60 mins minutes = totalminutes Mod 60 totalseconds = Int(CSng(interval * 86400)) ' 86400 = 1440 * 60 secs seconds = totalseconds Mod 60 If seconds 30 Then minutes = minutes + 1 ' round up the minutes and If minutes 59 Then hours = hours + 1: minutes = 0 ' adjust hours HoursAndMinutes = hours & ":" & Format(minutes, "00") End FunctionThe help is greatly appreciated!!"tina" wrote in message ... if there is a possibility that a record will have Receiving data entered, but not Disassembly data entered, *when you move to that record*, then change the Current event to If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If again, if you don't want the pop-ups on new blank records, then change the above to If Not Me.NewRecord Then If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If End If aside from the above, add the following code to the Receiving control's AfterUpdate event, as If IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If hth "PHisaw" wrote in message ... Tina, Thanks for the help! It worked, but can you now tell me how to keep a second popup from opening if it has null values. Ex: If "Receiving" is null, per your code below, it opens. I have another popup based on field "Disassembly" being null. I don't want both of them to open up when my main form opens, only "Receiving" and then when it is no longer null have "Disassembly" start opening. Is this possible? "tina" wrote: try adding code to the Current event of fGeneralInfo, as If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" End If if you only want the pop-up to open on existing records (not a new, blank record) then use If Not Me.NewRecord And IsNull(Me!Receiving) Then hth "Pam" wrote in message ... Tina, I got it to work - thanks so much! Can you help me open a pop up form already created based on a field being blank on another form? Ex: "fGeneralInfo" has field "Receiving". If "Receiving" is blank, I want form "fPopUpReceiving" to pop-up when fGeneralInfo opens with job info. I hope this isn't too confusing! Once again, the help is greatly appreciated!! "tina" wrote in message ... What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? do you mean "open *another* form" for the specific job number? if so, you can run code from the listbox control's Click event or AfterUpdate event to open the form with a WHERE clause, something along the lines of DoCmd.OpenForm "FormName", , , "JobNumber = " _ & Me!ListBoxName if the job number is a Text field, rather than a Number field, the syntax would be DoCmd.OpenForm "FormName", , , "JobNumber = '" _ & Me!ListBoxName & "'" in either case, the assumption is that the job number field is the bound column in the listbox control. hth "Pam" wrote in message ... I have a combo box and a list box on a form. The combo box lists tech names from a tech list table. The list box lists jobs related to each tech as they are selected in the combo box. What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? Any help is greatly appreciated!! Thanks, Pam |
#13
|
|||
|
|||
List Box to Open Form
Okay, I admit defeat with the HoursAndMinutes module. I have a field on my
form to calculate StartTime - Stop Time using the following in the control source row and this returns error msg "Invalid Syntax". I also need a calculated field in the footer of the form to calculate the Sum of these times. PLEASE HELP!!!! Very frustrated!!! =DateDiff("n", [TimeIn], [TimeOut]) \ 60 & ":" & _ Format(DateDiff("n", [TimeIn], [TimeOut]) Mod 60, "00") "tina" wrote in message ... in any module, from the menu bar click Edit | Find. in the Find dialog, in the Search section, choose Current Project, so all modules in the database will be searched. if you don't "find" another procedure with the same name, great. again, make sure that the standard module holding the procedure does *not* have the same name as the procedure. then, suggest you compile the code by clicking Debug | Compile from the menu bar; fix any errors that come up. then close any open objects (forms, modules, whatever) and compact/repair the database. then try running the function again. hth "Pam" wrote in message ... I see the module listing on the left side to where code is entered. The procedure is listed under "Modules". I clicked the heading "Class Modules" and all the associated forms opened. I opened "fWorkLog" form (where my calculated time field is located) and the command buttons, etc. associated with this form opened but not the procedure listed below. So it's not in both places, correct? I'm not very good with code - can figure a few thing out with cut & paste. Your help with this is very much appreciated!!! "tina" wrote in message ... did you have the procedure in a form's module, and then add it to a standard module - without deleting it from the form's module? if so, delete the procedure from the form module; you don't need it in both places. hth "Pam" wrote in message ... I went to Modules on the left side of the db window, clicked New and pasted the code in. I've changed the name several times and keep getting "The expression contains and ambiguous name. You may have two or more functions with the same name in different modules. Rename the functions so that each one has a unique name". The first time I did this with the Elapsed Time String it worked really well. "tina" wrote in message ... did you put the function in your form module? if so, try putting it in a standard module. make sure you don't give the module the same name as the procedure. hth "Pam" wrote in message ... Tina, Thank you so much for the prompt reply and it worked very well. Would you mind looking at the following code and letting me know what I'm doing wrong. I have set fields "StartTime" and "StopTime" and can get it to calculate on a field with an Elapsed Time String code for each record on a datasheet. I want to total the amount of time for the total job and have set up the following "HoursAndMinutes" module code. When I enter =HoursAndMinutes([StartTime]-[StopTime]) OR =HoursAndMinutes(Sum([StartTime]-[StopTime])), I get the msg "The object doesn't contain the Automation Object 'HoursAndMinutes' Public Function HoursAndMinutes(interval As Variant) As String '************************************************* ********************** ' Function HoursAndMinutes(interval As Variant) As String ' Returns time interval formatted as a hours:minutes string '************************************************* ********************** Dim totalminutes As Long, totalseconds As Long Dim hours As Long, minutes As Long, seconds As Long If IsNull(interval) = True Then Exit Function hours = Int(CSng(interval * 24)) totalminutes = Int(CSng(interval * 1440)) ' 1440 = 24 hrs * 60 mins minutes = totalminutes Mod 60 totalseconds = Int(CSng(interval * 86400)) ' 86400 = 1440 * 60 secs seconds = totalseconds Mod 60 If seconds 30 Then minutes = minutes + 1 ' round up the minutes and If minutes 59 Then hours = hours + 1: minutes = 0 ' adjust hours HoursAndMinutes = hours & ":" & Format(minutes, "00") End FunctionThe help is greatly appreciated!!"tina" wrote in message ... if there is a possibility that a record will have Receiving data entered, but not Disassembly data entered, *when you move to that record*, then change the Current event to If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If again, if you don't want the pop-ups on new blank records, then change the above to If Not Me.NewRecord Then If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If End If aside from the above, add the following code to the Receiving control's AfterUpdate event, as If IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If hth "PHisaw" wrote in message ... Tina, Thanks for the help! It worked, but can you now tell me how to keep a second popup from opening if it has null values. Ex: If "Receiving" is null, per your code below, it opens. I have another popup based on field "Disassembly" being null. I don't want both of them to open up when my main form opens, only "Receiving" and then when it is no longer null have "Disassembly" start opening. Is this possible? "tina" wrote: try adding code to the Current event of fGeneralInfo, as If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" End If if you only want the pop-up to open on existing records (not a new, blank record) then use If Not Me.NewRecord And IsNull(Me!Receiving) Then hth "Pam" wrote in message ... Tina, I got it to work - thanks so much! Can you help me open a pop up form already created based on a field being blank on another form? Ex: "fGeneralInfo" has field "Receiving". If "Receiving" is blank, I want form "fPopUpReceiving" to pop-up when fGeneralInfo opens with job info. I hope this isn't too confusing! Once again, the help is greatly appreciated!! "tina" wrote in message ... What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? do you mean "open *another* form" for the specific job number? if so, you can run code from the listbox control's Click event or AfterUpdate event to open the form with a WHERE clause, something along the lines of DoCmd.OpenForm "FormName", , , "JobNumber = " _ & Me!ListBoxName if the job number is a Text field, rather than a Number field, the syntax would be DoCmd.OpenForm "FormName", , , "JobNumber = '" _ & Me!ListBoxName & "'" in either case, the assumption is that the job number field is the bound column in the listbox control. hth "Pam" wrote in message ... I have a combo box and a list box on a form. The combo box lists tech names from a tech list table. The list box lists jobs related to each tech as they are selected in the combo box. What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? Any help is greatly appreciated!! Thanks, Pam |
#14
|
|||
|
|||
List Box to Open Form
you can't use a line break ( _) in a calculated control (the way you do in
VBA); the entire expression must be on one line, as =DateDiff("n", [TimeIn], [TimeOut]) \ 60 & ":" & Format(DateDiff("n", [TimeIn], [TimeOut]) Mod 60, "00") note that though the newsreader breaks this up into two lines, *you need to put it all on one line in the textbox control's ControlSource property. to sum the times of all records in the form's Footer section, try =Sum(DateDiff("n", [TimeIn], [TimeOut])) \ 60 & ":" & Format(Sum(DateDiff("n", [TimeIn], [TimeOut])) Mod 60, "00") hth "Pam" wrote in message ... Okay, I admit defeat with the HoursAndMinutes module. I have a field on my form to calculate StartTime - Stop Time using the following in the control source row and this returns error msg "Invalid Syntax". I also need a calculated field in the footer of the form to calculate the Sum of these times. PLEASE HELP!!!! Very frustrated!!! =DateDiff("n", [TimeIn], [TimeOut]) \ 60 & ":" & _ Format(DateDiff("n", [TimeIn], [TimeOut]) Mod 60, "00") "tina" wrote in message ... in any module, from the menu bar click Edit | Find. in the Find dialog, in the Search section, choose Current Project, so all modules in the database will be searched. if you don't "find" another procedure with the same name, great. again, make sure that the standard module holding the procedure does *not* have the same name as the procedure. then, suggest you compile the code by clicking Debug | Compile from the menu bar; fix any errors that come up. then close any open objects (forms, modules, whatever) and compact/repair the database. then try running the function again. hth "Pam" wrote in message ... I see the module listing on the left side to where code is entered. The procedure is listed under "Modules". I clicked the heading "Class Modules" and all the associated forms opened. I opened "fWorkLog" form (where my calculated time field is located) and the command buttons, etc. associated with this form opened but not the procedure listed below. So it's not in both places, correct? I'm not very good with code - can figure a few thing out with cut & paste. Your help with this is very much appreciated!!! "tina" wrote in message ... did you have the procedure in a form's module, and then add it to a standard module - without deleting it from the form's module? if so, delete the procedure from the form module; you don't need it in both places. hth "Pam" wrote in message ... I went to Modules on the left side of the db window, clicked New and pasted the code in. I've changed the name several times and keep getting "The expression contains and ambiguous name. You may have two or more functions with the same name in different modules. Rename the functions so that each one has a unique name". The first time I did this with the Elapsed Time String it worked really well. "tina" wrote in message ... did you put the function in your form module? if so, try putting it in a standard module. make sure you don't give the module the same name as the procedure. hth "Pam" wrote in message ... Tina, Thank you so much for the prompt reply and it worked very well. Would you mind looking at the following code and letting me know what I'm doing wrong. I have set fields "StartTime" and "StopTime" and can get it to calculate on a field with an Elapsed Time String code for each record on a datasheet. I want to total the amount of time for the total job and have set up the following "HoursAndMinutes" module code. When I enter =HoursAndMinutes([StartTime]-[StopTime]) OR =HoursAndMinutes(Sum([StartTime]-[StopTime])), I get the msg "The object doesn't contain the Automation Object 'HoursAndMinutes' Public Function HoursAndMinutes(interval As Variant) As String '************************************************* ********************** ' Function HoursAndMinutes(interval As Variant) As String ' Returns time interval formatted as a hours:minutes string '************************************************* ********************** Dim totalminutes As Long, totalseconds As Long Dim hours As Long, minutes As Long, seconds As Long If IsNull(interval) = True Then Exit Function hours = Int(CSng(interval * 24)) totalminutes = Int(CSng(interval * 1440)) ' 1440 = 24 hrs * 60 mins minutes = totalminutes Mod 60 totalseconds = Int(CSng(interval * 86400)) ' 86400 = 1440 * 60 secs seconds = totalseconds Mod 60 If seconds 30 Then minutes = minutes + 1 ' round up the minutes and If minutes 59 Then hours = hours + 1: minutes = 0 ' adjust hours HoursAndMinutes = hours & ":" & Format(minutes, "00") End FunctionThe help is greatly appreciated!!"tina" wrote in message ... if there is a possibility that a record will have Receiving data entered, but not Disassembly data entered, *when you move to that record*, then change the Current event to If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If again, if you don't want the pop-ups on new blank records, then change the above to If Not Me.NewRecord Then If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If End If aside from the above, add the following code to the Receiving control's AfterUpdate event, as If IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If hth "PHisaw" wrote in message ... Tina, Thanks for the help! It worked, but can you now tell me how to keep a second popup from opening if it has null values. Ex: If "Receiving" is null, per your code below, it opens. I have another popup based on field "Disassembly" being null. I don't want both of them to open up when my main form opens, only "Receiving" and then when it is no longer null have "Disassembly" start opening. Is this possible? "tina" wrote: try adding code to the Current event of fGeneralInfo, as If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" End If if you only want the pop-up to open on existing records (not a new, blank record) then use If Not Me.NewRecord And IsNull(Me!Receiving) Then hth "Pam" wrote in message ... Tina, I got it to work - thanks so much! Can you help me open a pop up form already created based on a field being blank on another form? Ex: "fGeneralInfo" has field "Receiving". If "Receiving" is blank, I want form "fPopUpReceiving" to pop-up when fGeneralInfo opens with job info. I hope this isn't too confusing! Once again, the help is greatly appreciated!! "tina" wrote in message ... What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? do you mean "open *another* form" for the specific job number? if so, you can run code from the listbox control's Click event or AfterUpdate event to open the form with a WHERE clause, something along the lines of DoCmd.OpenForm "FormName", , , "JobNumber = " _ & Me!ListBoxName if the job number is a Text field, rather than a Number field, the syntax would be DoCmd.OpenForm "FormName", , , "JobNumber = '" _ & Me!ListBoxName & "'" in either case, the assumption is that the job number field is the bound column in the listbox control. hth "Pam" wrote in message ... I have a combo box and a list box on a form. The combo box lists tech names from a tech list table. The list box lists jobs related to each tech as they are selected in the combo box. What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? Any help is greatly appreciated!! Thanks, Pam |
#15
|
|||
|
|||
List Box to Open Form
Tina,
It worked - I can't thank you enough for your time and help with this problem!! What you do is a great help to those of us trying to make these db's work!! Pam "tina" wrote in message ... you can't use a line break ( _) in a calculated control (the way you do in VBA); the entire expression must be on one line, as =DateDiff("n", [TimeIn], [TimeOut]) \ 60 & ":" & Format(DateDiff("n", [TimeIn], [TimeOut]) Mod 60, "00") note that though the newsreader breaks this up into two lines, *you need to put it all on one line in the textbox control's ControlSource property. to sum the times of all records in the form's Footer section, try =Sum(DateDiff("n", [TimeIn], [TimeOut])) \ 60 & ":" & Format(Sum(DateDiff("n", [TimeIn], [TimeOut])) Mod 60, "00") hth "Pam" wrote in message ... Okay, I admit defeat with the HoursAndMinutes module. I have a field on my form to calculate StartTime - Stop Time using the following in the control source row and this returns error msg "Invalid Syntax". I also need a calculated field in the footer of the form to calculate the Sum of these times. PLEASE HELP!!!! Very frustrated!!! =DateDiff("n", [TimeIn], [TimeOut]) \ 60 & ":" & _ Format(DateDiff("n", [TimeIn], [TimeOut]) Mod 60, "00") "tina" wrote in message ... in any module, from the menu bar click Edit | Find. in the Find dialog, in the Search section, choose Current Project, so all modules in the database will be searched. if you don't "find" another procedure with the same name, great. again, make sure that the standard module holding the procedure does *not* have the same name as the procedure. then, suggest you compile the code by clicking Debug | Compile from the menu bar; fix any errors that come up. then close any open objects (forms, modules, whatever) and compact/repair the database. then try running the function again. hth "Pam" wrote in message ... I see the module listing on the left side to where code is entered. The procedure is listed under "Modules". I clicked the heading "Class Modules" and all the associated forms opened. I opened "fWorkLog" form (where my calculated time field is located) and the command buttons, etc. associated with this form opened but not the procedure listed below. So it's not in both places, correct? I'm not very good with code - can figure a few thing out with cut & paste. Your help with this is very much appreciated!!! "tina" wrote in message ... did you have the procedure in a form's module, and then add it to a standard module - without deleting it from the form's module? if so, delete the procedure from the form module; you don't need it in both places. hth "Pam" wrote in message ... I went to Modules on the left side of the db window, clicked New and pasted the code in. I've changed the name several times and keep getting "The expression contains and ambiguous name. You may have two or more functions with the same name in different modules. Rename the functions so that each one has a unique name". The first time I did this with the Elapsed Time String it worked really well. "tina" wrote in message ... did you put the function in your form module? if so, try putting it in a standard module. make sure you don't give the module the same name as the procedure. hth "Pam" wrote in message ... Tina, Thank you so much for the prompt reply and it worked very well. Would you mind looking at the following code and letting me know what I'm doing wrong. I have set fields "StartTime" and "StopTime" and can get it to calculate on a field with an Elapsed Time String code for each record on a datasheet. I want to total the amount of time for the total job and have set up the following "HoursAndMinutes" module code. When I enter =HoursAndMinutes([StartTime]-[StopTime]) OR =HoursAndMinutes(Sum([StartTime]-[StopTime])), I get the msg "The object doesn't contain the Automation Object 'HoursAndMinutes' Public Function HoursAndMinutes(interval As Variant) As String '************************************************* ********************** ' Function HoursAndMinutes(interval As Variant) As String ' Returns time interval formatted as a hours:minutes string '************************************************* ********************** Dim totalminutes As Long, totalseconds As Long Dim hours As Long, minutes As Long, seconds As Long If IsNull(interval) = True Then Exit Function hours = Int(CSng(interval * 24)) totalminutes = Int(CSng(interval * 1440)) ' 1440 = 24 hrs * 60 mins minutes = totalminutes Mod 60 totalseconds = Int(CSng(interval * 86400)) ' 86400 = 1440 * 60 secs seconds = totalseconds Mod 60 If seconds 30 Then minutes = minutes + 1 ' round up the minutes and If minutes 59 Then hours = hours + 1: minutes = 0 ' adjust hours HoursAndMinutes = hours & ":" & Format(minutes, "00") End FunctionThe help is greatly appreciated!!"tina" wrote in message ... if there is a possibility that a record will have Receiving data entered, but not Disassembly data entered, *when you move to that record*, then change the Current event to If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If again, if you don't want the pop-ups on new blank records, then change the above to If Not Me.NewRecord Then If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If End If aside from the above, add the following code to the Receiving control's AfterUpdate event, as If IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If hth "PHisaw" wrote in message ... Tina, Thanks for the help! It worked, but can you now tell me how to keep a second popup from opening if it has null values. Ex: If "Receiving" is null, per your code below, it opens. I have another popup based on field "Disassembly" being null. I don't want both of them to open up when my main form opens, only "Receiving" and then when it is no longer null have "Disassembly" start opening. Is this possible? "tina" wrote: try adding code to the Current event of fGeneralInfo, as If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" End If if you only want the pop-up to open on existing records (not a new, blank record) then use If Not Me.NewRecord And IsNull(Me!Receiving) Then hth "Pam" wrote in message ... Tina, I got it to work - thanks so much! Can you help me open a pop up form already created based on a field being blank on another form? Ex: "fGeneralInfo" has field "Receiving". If "Receiving" is blank, I want form "fPopUpReceiving" to pop-up when fGeneralInfo opens with job info. I hope this isn't too confusing! Once again, the help is greatly appreciated!! "tina" wrote in message ... What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? do you mean "open *another* form" for the specific job number? if so, you can run code from the listbox control's Click event or AfterUpdate event to open the form with a WHERE clause, something along the lines of DoCmd.OpenForm "FormName", , , "JobNumber = " _ & Me!ListBoxName if the job number is a Text field, rather than a Number field, the syntax would be DoCmd.OpenForm "FormName", , , "JobNumber = '" _ & Me!ListBoxName & "'" in either case, the assumption is that the job number field is the bound column in the listbox control. hth "Pam" wrote in message ... I have a combo box and a list box on a form. The combo box lists tech names from a tech list table. The list box lists jobs related to each tech as they are selected in the combo box. What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? Any help is greatly appreciated!! Thanks, Pam |
#16
|
|||
|
|||
List Box to Open Form
you're very welcome!
"Pam" wrote in message ... Tina, It worked - I can't thank you enough for your time and help with this problem!! What you do is a great help to those of us trying to make these db's work!! Pam "tina" wrote in message ... you can't use a line break ( _) in a calculated control (the way you do in VBA); the entire expression must be on one line, as =DateDiff("n", [TimeIn], [TimeOut]) \ 60 & ":" & Format(DateDiff("n", [TimeIn], [TimeOut]) Mod 60, "00") note that though the newsreader breaks this up into two lines, *you need to put it all on one line in the textbox control's ControlSource property. to sum the times of all records in the form's Footer section, try =Sum(DateDiff("n", [TimeIn], [TimeOut])) \ 60 & ":" & Format(Sum(DateDiff("n", [TimeIn], [TimeOut])) Mod 60, "00") hth "Pam" wrote in message ... Okay, I admit defeat with the HoursAndMinutes module. I have a field on my form to calculate StartTime - Stop Time using the following in the control source row and this returns error msg "Invalid Syntax". I also need a calculated field in the footer of the form to calculate the Sum of these times. PLEASE HELP!!!! Very frustrated!!! =DateDiff("n", [TimeIn], [TimeOut]) \ 60 & ":" & _ Format(DateDiff("n", [TimeIn], [TimeOut]) Mod 60, "00") "tina" wrote in message ... in any module, from the menu bar click Edit | Find. in the Find dialog, in the Search section, choose Current Project, so all modules in the database will be searched. if you don't "find" another procedure with the same name, great. again, make sure that the standard module holding the procedure does *not* have the same name as the procedure. then, suggest you compile the code by clicking Debug | Compile from the menu bar; fix any errors that come up. then close any open objects (forms, modules, whatever) and compact/repair the database. then try running the function again. hth "Pam" wrote in message ... I see the module listing on the left side to where code is entered. The procedure is listed under "Modules". I clicked the heading "Class Modules" and all the associated forms opened. I opened "fWorkLog" form (where my calculated time field is located) and the command buttons, etc. associated with this form opened but not the procedure listed below. So it's not in both places, correct? I'm not very good with code - can figure a few thing out with cut & paste. Your help with this is very much appreciated!!! "tina" wrote in message ... did you have the procedure in a form's module, and then add it to a standard module - without deleting it from the form's module? if so, delete the procedure from the form module; you don't need it in both places. hth "Pam" wrote in message ... I went to Modules on the left side of the db window, clicked New and pasted the code in. I've changed the name several times and keep getting "The expression contains and ambiguous name. You may have two or more functions with the same name in different modules. Rename the functions so that each one has a unique name". The first time I did this with the Elapsed Time String it worked really well. "tina" wrote in message ... did you put the function in your form module? if so, try putting it in a standard module. make sure you don't give the module the same name as the procedure. hth "Pam" wrote in message ... Tina, Thank you so much for the prompt reply and it worked very well. Would you mind looking at the following code and letting me know what I'm doing wrong. I have set fields "StartTime" and "StopTime" and can get it to calculate on a field with an Elapsed Time String code for each record on a datasheet. I want to total the amount of time for the total job and have set up the following "HoursAndMinutes" module code. When I enter =HoursAndMinutes([StartTime]-[StopTime]) OR =HoursAndMinutes(Sum([StartTime]-[StopTime])), I get the msg "The object doesn't contain the Automation Object 'HoursAndMinutes' Public Function HoursAndMinutes(interval As Variant) As String '************************************************* ********************** ' Function HoursAndMinutes(interval As Variant) As String ' Returns time interval formatted as a hours:minutes string '************************************************* ********************** Dim totalminutes As Long, totalseconds As Long Dim hours As Long, minutes As Long, seconds As Long If IsNull(interval) = True Then Exit Function hours = Int(CSng(interval * 24)) totalminutes = Int(CSng(interval * 1440)) ' 1440 = 24 hrs * 60 mins minutes = totalminutes Mod 60 totalseconds = Int(CSng(interval * 86400)) ' 86400 = 1440 * 60 secs seconds = totalseconds Mod 60 If seconds 30 Then minutes = minutes + 1 ' round up the minutes and If minutes 59 Then hours = hours + 1: minutes = 0 ' adjust hours HoursAndMinutes = hours & ":" & Format(minutes, "00") End FunctionThe help is greatly appreciated!!"tina" wrote in message ... if there is a possibility that a record will have Receiving data entered, but not Disassembly data entered, *when you move to that record*, then change the Current event to If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If again, if you don't want the pop-ups on new blank records, then change the above to If Not Me.NewRecord Then If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" ElseIf IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If End If aside from the above, add the following code to the Receiving control's AfterUpdate event, as If IsNull(Me!Disassembly) Then DoCmd.OpenForm "DisassemblyFormName" End If hth "PHisaw" wrote in message ... Tina, Thanks for the help! It worked, but can you now tell me how to keep a second popup from opening if it has null values. Ex: If "Receiving" is null, per your code below, it opens. I have another popup based on field "Disassembly" being null. I don't want both of them to open up when my main form opens, only "Receiving" and then when it is no longer null have "Disassembly" start opening. Is this possible? "tina" wrote: try adding code to the Current event of fGeneralInfo, as If IsNull(Me!Receiving) Then DoCmd.OpenForm "fPopUpReceiving" End If if you only want the pop-up to open on existing records (not a new, blank record) then use If Not Me.NewRecord And IsNull(Me!Receiving) Then hth "Pam" wrote in message ... Tina, I got it to work - thanks so much! Can you help me open a pop up form already created based on a field being blank on another form? Ex: "fGeneralInfo" has field "Receiving". If "Receiving" is blank, I want form "fPopUpReceiving" to pop-up when fGeneralInfo opens with job info. I hope this isn't too confusing! Once again, the help is greatly appreciated!! "tina" wrote in message ... What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? do you mean "open *another* form" for the specific job number? if so, you can run code from the listbox control's Click event or AfterUpdate event to open the form with a WHERE clause, something along the lines of DoCmd.OpenForm "FormName", , , "JobNumber = " _ & Me!ListBoxName if the job number is a Text field, rather than a Number field, the syntax would be DoCmd.OpenForm "FormName", , , "JobNumber = '" _ & Me!ListBoxName & "'" in either case, the assumption is that the job number field is the bound column in the listbox control. hth "Pam" wrote in message ... I have a combo box and a list box on a form. The combo box lists tech names from a tech list table. The list box lists jobs related to each tech as they are selected in the combo box. What I want to be able to do is click on one of the jobs in the list box and have it open the form for that specific job number? Any help is greatly appreciated!! Thanks, Pam |
|
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Form won't open report from preview button | jwr | Using Forms | 5 | October 29th, 2005 04:53 PM |
Need Help In Printing Current Record in Specific Report | RNUSZ@OKDPS | Setting Up & Running Reports | 1 | May 16th, 2005 09:06 PM |
Design help, please | SillySally | Using Forms | 27 | March 6th, 2005 04:11 AM |
Strange stLinkCriteria behaviour on command button | Anthony Dowd | Using Forms | 3 | August 21st, 2004 03:01 AM |
dlookup | miaplacidus | Using Forms | 9 | August 5th, 2004 09:16 PM |